Airdrop Contracts

Key Features

  • ERC20 Token Distribution: Supports airdropping any ERC20 token

  • Merkle Proof Verification: Uses cryptographic proofs to verify claim eligibility

  • Gas Efficient: Only stores one Merkle root instead of all user data

  • Claim Tracking: Prevents double-claiming by maintaining a record of claimed addresses

  • Owner Controls: Allows the owner to update the Merkle root and withdraw unclaimed tokens

MerkleAirdrop Contract

A contract that implements a Merkle tree–based airdrop for ERC20 tokens with controlled claim processing and robust admin management.

Features

  • Merkle Tree Eligibility:

    • Utilizes a stored Merkle root to verify if an address is eligible for the airdrop.

    • The inMerkle() function checks a user's address and claim amount against the Merkle proof.

  • Claiming Process:

    • Users can claim tokens via the claim() function if they are eligible.

    • Prevents double claims by tracking claims in a mapping.

    • Emits a Claimed event on successful claims.

  • Admin Controls:

    • The owner can update the Merkle root using the updateMerkleRoot() function.

    • Allows the owner to withdraw tokens from the contract with the withdraw() function.

Inheritance

  • ReentrancyGuard: Provides protection against reentrancy attacks on critical functions.

  • Ownable: Restricts sensitive functions to the contract owner.

Key Functions

  • claim(uint256 amount, bytes32[] calldata proof): Allows eligible users to claim their tokens if their Merkle proof is valid.

  • inMerkle(address who, uint256 amount, bytes32[] calldata proof): Verifies that the address and claim amount are part of the Merkle tree.

  • hasClaimed(address who): Checks whether an address has already claimed the airdrop.

  • updateMerkleRoot(bytes32 _root): Enables the owner to update the Merkle root to adjust eligibility.

  • withdraw(address recipient, uint256 amount): Allows the owner to withdraw tokens from the contract if needed.

Security Features

  • Reentrancy Protection: Critical functions (like claim()) are secured against reentrant calls.

  • Safe Transfers: Utilizes the SafeERC20 library to ensure secure token transfers.

  • Access Control: Owner-only functions safeguard administrative tasks such as updating the Merkle root and withdrawing tokens.

Last updated