I am creating an NFT game and I want to create an airdrop for other token holders. I have the addresses of holders, it's more than 20 thousand addresses. Now my question is, how do I make the addresses eligible for the airdrop?

What I want to do is something like Uniswap did, you click on claim and it tells you if you have some airdrop or you don't. And if you do, you can claim it.

So in my contract, if you are eligible for the airdrop, you click on claim, then the token is minted and transferred to you, so all the gas is on you.

But my question is how do I tell the contract which address is eligible for the airdrop? What I have tried is that I created a

mapping(address => uint) private _airdrop;

and then a function

function registerAirdrop(address user, uint tokenId) public onlyOwner {
   _airdrop[user] = tokenId;

and then called the function 20 thousand times, for each address, but I quickly realized that this would not be either time or gas efficient. Is there a better way? How could I tell my smart contract which addresses are able to claim airdrop?

1 Answer 1


You can use a merkle tree and only store the root in the contract, see Using OpenZeppelin merkle proof library.

Publish the entire tree and a user to redeem has to calculate the branch and send from their address.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.