-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathairdrop.js
38 lines (33 loc) · 1.92 KB
/
airdrop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { ethers } = require('ethers');
const airdropAbi = [
'function bulkAirdropERC20(address _token, address[] _to, uint256[] _value) external',
'function bulkAirdropERC721(address _token, address[] _to, uint256[] _id) external'
];
const airdropAddress = '0x811512Fd8079252E4e5888eBfebE2589c9515480'; // Replace with the Airdrop contract address
const providerUrl = 'https://sepolia.infura.io/v3/fb42577745e24d429d936f65b43cca0b'; // Replace with the Ethereum node URL
const privateKey = 'fdc3d7a7ef1129116fbf4d565cff4ce9f86570e67ed6a7cf84281acab26986fc'; // Replace with the private key of the sending address
const provider = new ethers.providers.JsonRpcProvider(providerUrl);
const wallet = new ethers.Wallet(privateKey, provider);
const airdropContract = new ethers.Contract(airdropAddress, airdropAbi, wallet);
async function bulkAirdropERC20(tokenAddress, recipients, amounts) {
const tokenContract = new ethers.Contract(tokenAddress, ['function approve(address spender, uint256 amount) returns (bool)'], wallet);
await tokenContract.approve(airdropAddress, ethers.constants.MaxUint256);
await airdropContract.bulkAirdropERC20(tokenAddress, recipients, amounts);
}
async function bulkAirdropERC721() {
const tokenAddress = '0xCF2f99838637A447A27c698128cbd174b1BCAFBf'; // set token address here
const recipients = ['0x5bB80ecf6d7b8D7421EeAfa71dD6beAe60b8841f', '0x3A98Be1D1628B6A107BC2636cB2d4a4C422B59E5']; // set recipient addresses here
const ids = [4, 5]; // set token ids here
await airdropContract.bulkAirdropERC721(tokenAddress, recipients, ids);
}
// Parse command line arguments
const args = process.argv.slice(2);
// Call appropriate function based on command line arguments
if (args[0] === 'erc20') {
bulkAirdropERC20(tokenAddress, recipients, amounts);
} else if (args[0] === 'erc721') {
bulkAirdropERC721();
} else {
console.log('Invalid command');
}
//erc721: node airdrop.js erc721 addresses tokenIds