MerkleTokenVesting Smart Contract Module in Bunzz

We are excited to announce our new MerkleTokenVesting Module available in Bunzz and created by Deep-Quality-Dev.

This token vesting contract is based on a Merkle Tree. A merkle tree, also known as binary hash tree, is a mathematical data structure made up of hashes of various data blocks that summarize all the transactions in a block. It also enables quick and secure content verification across big datasets and verifies the consistency and content of the data. In Bitcoin and other cryptocurrencies, they’re used to encrypt blockchain data more efficiently and securely.

The MerkleTokenVesting module contains two main functionalities:

  • Token vesting that vests the balance of any ERC20 token to beneficiaries gradually in a linear fashion until _start + _duration. By then all of the balance will have been vested.
  • Verify the beneficiary through a merkle tree.

The Struct is defined like this:

struct TokenAward {

uint26 amount;

uint256 released;

bool revocable;

bool revoked;

}

You can access this Module and the code here: https://bit.ly/3ht7qOe

How to Use

  1. Prepare the vesting schedule in block number: start, cliff, duration and vesting token.
  2. Prepare the whitelist and their vesting amount, generate the merkle tree and output to the JSON file. Check JSON file format as below*. It contains the merkle root, the total token amount for vesting, the individual token amounts and the list of merkle proof.
  3. Deploy MerkleTokenVesting with vesting schedule and merkle root.
  4. Transfer assets to this contract.
  5. Beneficiaries can check their releasable amount and vested amount by the getReleasableAmount, getVestedAmount functions.
  6. Beneficiaries can claim their vested tokens after cliff by calling the claimAward function.
  7. Only verified users can claim.

*JSON format: JSON file represents which accounts will be allowed and their proofs, awarded amount, and revocable. Each item in claims will be used as a parameter for the claimAward function. (See full file content opening the repository link).

Functions

#WRITE

  • transferOwnership
  • renounceOwnership
  • revoke
  • release
  • connectToOtherContracts
  • claimAward

#READ

  • vestingStart
  • targetToken
  • vestingDuration
  • vestingCliff
  • getVestedAmount
  • isClaimed
  • merkleRoot
  • owner
  • getReleasableAmount
  • awards

You can access this Module and the code here: https://bit.ly/3ht7qOe

If you still haven’t signed up to Bunzz, what are you waiting for?

Sign up here https://app.bunzz.dev/signup and get your smart contracts deployed in 5 minutes through our great GUI.

Share this article: