How to create a merkle tree and get merkle root for merkle distributor contract?

Hi, I’m learning how to deploy a Merkle distributor contract. I have looked at some tutorial like https://github.com/aidigidreamers/merkle-distributor/blob/master/src/merkle-tree.ts, and
What to provide in the proof parameter of the verify function for the MerkleProof library

But I’m still feeling a little confused to implement the operation. I don’t know how to get Merkle root via Merkle-tree.js and my transactions like blow:
0x001873abd9b26447a7a6ab2e41ddd6a8da3be08a 10000
0x0208bf7897cd6240a6cad7d972f4b8b3b1cd9a5a 1000
0x03377073f2421fc3d9eafe9e235a820c4038ec8b 10000

Please help!

1 Like

I am not similar with the merkle proof contract, I only know the uniswap token distribution, maybe it can give you some idea.

2 Likes

Thanks for your replying, that’s the idea I referred to. I think the logic of the contract is not complicated, but not familiar with the Merkle proof as well as you. whatever, thanks for your help

1 Like

Hi @uua,

I haven’t played with it beyond what you found: What to provide in the proof parameter of the verify function for the MerkleProof library

I assume you can encode/concatenate the data of the address and the amount of tokens and use the Uniswap example @skyge gave you. (Thanks as always @skyge :pray:)

1 Like

Thanks, I have found the solution of how to generate a Merkle root in Uniswap’s GitHub repo(Merkle Distributor) and love to share it with you:

In short, I need to execute the “generate_merkle_root.tx” file with the following code:
ts-node scripts/generate-merkle-root.ts --input scripts/airdrop_list.json

p.s.
1 airdrop_list.json is customized on my own. It is a white list and the format is the following:

{
  "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f": "100"
}

2 execute the following code on your own computer
npm install -g typescript
npm install -g ts-node

1 Like

Hi @uua,

Thanks for sharing :pray:

For anyone reading this, the script is here:

2 Likes