This guide will allow you to send any ERC20 token to a list of wallet addresses. If you don't already have a token, you can deploy one from the Token - ERC20 page.
Deploy the Airdrop Smart Contract
To deploy the contract, head to the Contracts page in your thirdweb Dashboard and hit "Deploy new contract":
You will be taken to our Explore page — where you can browse smart contracts built by the top protocols in web3 and deploy them in just a few clicks!
Note: You can also use the thirdweb CLI to set up a smart contract environment by running the below command from your terminal:
npx thirdweb create contract
This will take you through an easy-to-follow flow of steps for you to create your contract. Learn more about this in our CLI guide.
Otherwise, let's get back to Explore:
Scroll down to the Airdrops section, and click on the Airdrop ERC-20 contract. Deploy the contract by clicking the
Deploy Now button, and entering the wallet address you want to be the owner of the contract (the default value is the connected wallet address).
Once you click
Deploy Now, you'll be taken to your contract's dashboard page! 🎉
Set Approval For Tokens
The way the ERC20 airdrop contract works is by transferring funds from the owner's wallet to the list of recipient wallets. In order for a smart contract to transfer funds from your wallet, you need to explicitly approve it to do so.
To do that, we need to run the
approve function on the ERC20 smart contract. Head to the
Explorer tab of your Token smart contract, and enter the following parameters on the
spender: Paste in the address of the Airdrop contract.
amount: Total amount of tokens you're going to be airdropping.
Below, we're granting the airdrop smart contract to have permission to spend
50 of our custom ERC20 tokens.
Execute to give your airdrop smart contract permission to transfer your tokens!
Airdropping ERC20 Tokens
Back in the Airdrop contract, head to the Explorer tab and use the
airdrop function with the following parameters:
_tokenAddress: The address of the ERC20 token being transferred. (For native tokens such as Ether, this is
_tokenOwner: The wallet address that contains the funds to be transferred (the wallet we just ran
approvefrom in the step above).
_recipients: The list of recipients of the airdrop.
_amounts: The corresponding list for the amount of tokens to airdrop per recipient in the recipient list.
Here's a good example:
After executing the function you will approve a transaction and the airdrop will be successfully completed! 🛩️
In this guide, we learned how we can airdrop ERC-20 tokens to different wallets using the dashboard. If you run into any issues while following this guide, feel free to reach out to us on our Discord server to speak to our team directly!