3

I am writing an ERC20 token contract (contract token) with a mint of 2 million tokens. I am also writing a Merkle tree airdrop contract and sending it to this contract (contract Merkle tree). So, let's say the Merkle tree contract has been supplied/sent 1 million tokens from the token contract.

When other users call the function to claim the tokens, will the Merkle tree airdrop contract automatically take the tokens and send them to the other users who pay the transaction fee? Or will it trigger the ERC20 smart contract? I am currently studying about Merkle tree airdrop smart contracts. Please help me, thank you.

2
  • Please, share the code contracts. Without the code we don't know what they are doing.
    – Ismael
    Commented Jan 19, 2023 at 14:28
  • At Sablier, we've built our own airdrop solution (called Airstreams), and we've open-sourced our Merkle tree generator. Commented Feb 4 at 14:02

1 Answer 1

0

That depends on your design preferences. I would suggest including the MerkleProofs in the ERC20 contract itself since it will save you gas and complexity.

Merkle trees are usually used in a way where the admin sends a Merkle root, which includes all the "whitelisted" addresses, to the smart contract. When the user later wants to trigger a whitelisted mint, the project's webpage generates proof for the user's address, which is then sent as a parameter in the transaction.

Verify method in Openzeppelin's MerkleProof looks like this:

verify(bytes32[] proof, bytes32 root, bytes32 leaf)

where

  • Proof is generated on the page
  • Root is supplied from the smart contract itself
  • Leaf is msg.sender (sender's address)

So to answer your question it will trigger ERC20 smart contract's mint function.

1
  • solved! thankyou
    – Ingrosso
    Commented Feb 3, 2023 at 6:41

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.