This smart contract is designed for distributing tokens with a vesting schedule where:
- 31% of tokens are released at the Token Generation Event (TGE).
- 69% of tokens are released linearly over time.
- Merkle Tree: Utilizes a Merkle tree for efficient and secure distribution of token allocations.
- Vesting Schedule: Tokens are vested from
vesting_start_time
tovesting_end_time
. - Claim Functionality: Allows users to claim their vested tokens based on proof provided in the Merkle tree.
- Deploy: Deploy the contract with necessary parameters like Merkle root, token address, and vesting times.
- Claim: Users can claim tokens by providing a Merkle proof of their allocation.
__init__(merkle_root, token, vesting_start_time, vesting_end_time)
: Sets up the contract with initial parameters.
_hash_pair(a, b)
: Helper function to hash two bytes32 values._verify_proof(proof, leaf)
: Verifies a Merkle proof against the root.verify_proof(user, amount, proof)
: Public-facing function to verify proof for a user's claim.
claim(user, total_amount, proof)
: Allows users or anyone on behalf of users to claim vested tokens.
set_merkle_root(merkle_root)
: Updates the Merkle root (only callable by owner).rescue_tokens(to, amount)
: Emergency function to rescue tokens (only callable by owner).
_calculate_vested_amount(total_amount)
: Calculates how much of the total allocation is vested based on current time.claimable_amount(user, total_amount)
: Calculates claimable amount for a user without proof verification.
- View Function Warning:
- Do not use the
claimable_amount
function in on-chain logic as it does not verify the user's proof against the Merkle root. This function is meant for frontend UI to display possible claimable amounts but should not influence contract behavior directly.
- Do not use the
- Owner Privileges: Functions like
set_merkle_root
andrescue_tokens
can only be called by the contract owner. - Merkle Proof: Any claim must be accompanied by a valid Merkle proof to ensure only authorized users can claim tokens.