Airdrop ERC20 Tokens to a List of Wallet Addresses

Airdrop ERC20 Tokens to a List of Wallet Addresses - thirdweb Guides

In this guide, we will learn how to airdrop ERC20 tokens to a list of recipients using the new Airdrop ERC20 contract from the dashboard!

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":

deploy new contract
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:

thirdweb explore page
thirdweb explore page


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).

Add a default admin and deploy the contract
Add a default admin and deploy the contract

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 approve function:

  • 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.

Approve the airdrop contract to spend tokens
Approve the airdrop contract to spend tokens

Click 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 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE).
  • _tokenOwner: The wallet address that contains the funds to be transferred (the wallet we just ran approve from 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:

Use the airdrop function to airdrop the tokens
Use the airdrop function to airdrop the tokens

After executing the function you will approve a transaction and the airdrop will be successfully completed! 🛩️

Conclusion

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!