Merkle Tree Airdrop Smart Contract Module in Bunzz

The MerkleTreeAirdrop contract module acts as Airdrop for ERC20. It only sends out tokens on data verification, i.e., Merkle proof and appropriate arguments used to build the Merkle tree for that user. The contract requires a list of wallet addresses and root hash, which are the leaves and Merkle proofs needed to verify that a given data exists for that address in the tree.

You can access this Module and the code here.

How to use

  1. Prepare an ERC20 token as an airdrop token. You can use an existing token or deploy a new ERC20 token on the DApp’s page.
  2. Prepare the whitelist and their drop amount, generate the Merkle tree, and output to the JSON file. Check the JSON file format below. It contains the Merkle root, the total token amount for airdrop, individual token amounts, and a list of Merkle proofs.
  3. Deploy MerkleTreeAirdrop contract with Merkle root.
  4. Transfer drop assets to this contract.
  5. Beneficiaries can claim their drop tokens by claim function.
  6. Only verified users can claim.
{
  "merkleRoot": "0x73e9ab882da5e26fbfb0323ad8c171fa34847aedf17518960144a3d7712b8fb0",
  "tokenTotal": "12000000",
  "claims": {
    "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65": {
      "index": 0,
      "amount": "5000000",
      "proof": [
        "0x7084f9587399496b678c3c3bc2e260bde1a36c4ef20e5ba31a6586a78ea84052",
        "0xca1fa0f64eefb1c6dd3e7f07e195c823422dc15d36b308bcbd96c972f031c060"
      ]
    },
    "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC": {
      "index": 1,
      "amount": "1000000",
      "proof": [
        "0xf7f4759620b7517d89196c50cee28b670bc9269d7671dfd9a403e79ba1dda996",
        "0x8e20e72ee3a98a39b7fb5b1b7eb0bd446a6bfadf5ed012e0f5d29220312c1076"
      ]
    }
  }
}

Functions

#WRITE

  • connectToOtherContracts
  • renounceOwnership
  • claim
  • transferOwnership

#READ

  • isClaimed
  • merkleRoot
  • owner
  • token
Share this article: