I am trying to understand why Merkle Distributor
AKA merkle airdrop is used. I understand how it works, but what I don't understand is why it's a better option.
People use it when there's ICO and they want to distribute tokens, my problem is that I don't see a lot of advantage of it. Let's say we use a traditional distribution.
- we write ERC20 token contract. (
contract1
) - we write another contract which creates lots of tokens and sends it to this contract. (
contract2
) . Socontract2
has let's say 1000000000000 tokens. - other users call the function
buyTokens
oncontract2
and in that function, we check how much ethers they pay and according to it, we calculate how many tokens to give to the users. Then, we calladdress(ERC20).transfer(to, amount)
. This seems to work fine. **It's the user that pays the transaction fee`.
Could you explain why Merkle Distributor
makes sense here and what advantage it has ? I know what it is and how it exactly works, so no need to explain it too much.
Best Answer
The Merkle distributor is more useful when you have a predefined list of addresses that should receive the tokens. In the ICO model, anybody can buy the tokens. In an Airdrop model only some addresses can receive the token. The question becomes, how do we make ensure that some specific people receive the tokens? You can send it directly to all of them. This is expensive. You can store a mapping of all the allowed addresses within your contract. This is expensive for the deployer. Or you can have a merkle root within your Merkle Distributor. This approach reduces your cost for deployment while allowing the user to withdraw their airdrop tokens. I hope that answers your question.