LogoLogo
  • Introduction
  • For Founders
    • TokenTable Airdrop Pro
    • TokenTable Airdrop Lite
      • Getting Started
      • Set Up the Project
      • Deposit Tokens
      • Publish the Project
    • TokenTable Unlocker
    • Custom Token Claiming Portal
  • For Token Recipients
    • Airdrop Token Claiming
    • Unlocker Token Claiming
  • For Developers
    • Airdrop
      • EVM
        • Deployer
        • Merkle Distributor
        • Signature Distributor
        • Changelog
      • TON
        • Getting Started
        • Architecture
        • Usage
        • Smart Contract Schema
        • Integration
    • Unlocker
      • EVM
        • APIs
          • Core
            • Unlocker
              • Data Models
            • FutureToken
            • TrackerToken
          • Utilities
            • Deployer
            • External Hook
            • Fee Collector
            • Versionable
        • SDK
      • Starknet
  • SUPPORT
    • FAQ
    • Feedback and Troubleshooting
Powered by GitBook
On this page
  • Introduction
  • πŸš€ Quick Start
  • What is a Merkle Distributor?
  • Key Benefits
  • πŸ“‹ System Overview
  • Architecture Diagram
  • Core Components
  • πŸ”§ Core Contracts
  • BaseMerkleDistributor
  • πŸ”Œ Extension Contracts
  • ERC20 Extensions
  • ERC721 Extensions
  • Custom Extensions
  • πŸ’° Fee System
  • Overview
  • Components
  • Configuration
  • πŸ”’ Security
  • Access Control
  • Security Features
  • πŸ“‘ Events & Errors
  • Events
  • Errors

Was this helpful?

  1. For Developers
  2. Airdrop
  3. EVM

Merkle Distributor

Introduction

The Merkle Distributor provides a modular and efficient solution for token distribution using merkle proofs, supporting various token standards and customizable distribution patterns.

πŸš€ Quick Start

What is a Merkle Distributor?

A Merkle Distributor is a smart contract system that enables efficient and verifiable token airdrops. Instead of storing all recipient data on-chain, it uses a Merkle tree where only the root is stored, significantly reducing gas costs while maintaining security.

Key Benefits

  • βœ… Gas Efficient - Only stores Merkle root on-chain

  • βœ… Verifiable - Claims are cryptographically proven

  • βœ… Flexible - Supports multiple token types and distribution patterns

  • βœ… Secure - Built with security best practices

πŸ“‹ System Overview

Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                MDCreate2 Factory                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ Deploys
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               BaseMerkleDistributor                β”‚
β”‚      (Abstract base with core functionality)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ Inherited by
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                                 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ERC20 Extensions β”‚           β”‚  ERC721 Extensions  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Components

  • Base Contract - Core distribution logic

  • Extensions - Token-specific implementations

  • Custom Extensions - Special use cases

πŸ”§ Core Contracts

BaseMerkleDistributor

The foundation contract providing core distribution functionality.

Key Features

Storage Pattern (ERC7201)

The contract uses ERC7201 storage pattern:

struct BaseMerkleDistributorStorage {
    mapping(bytes32 leaf => bool used) usedLeafs;
    bytes32 root;
    address deployer;
    address token;
    address claimDelegate;
    uint256 startTime;
    uint256 endTime;
    address claimHook;
}

Claim Mechanism

Two ways to claim tokens:

  1. Direct Claim - Recipients claim their own tokens

  2. Delegate Claim - Authorized delegate claims for recipients

function claim(
    bytes32[] calldata proof,
    bytes32 group,
    bytes calldata data,
    bytes calldata extraData
) external payable

Security Features

  • Reentrancy protection on all claim functions

  • Double-claim prevention via leaf tracking

  • Time-based access control

  • Owner-only administrative functions

πŸ”Œ Extension Contracts

ERC20 Extensions

TokenTableMerkleDistributor

Standard ERC20 token distribution with time-locked claims.

struct TokenTableMerkleDistributorData {
    uint256 index;
    uint256 claimableTimestamp;
    uint256 claimableAmount;
}

TokenTableNativeMerkleDistributor

Distributes native tokens (ETH) with similar functionality.

Special Features:

  • Handles ETH transfers

  • receive() function for accepting ETH

  • Native token withdrawal support

ERC721 Extensions

SimpleERC721MerkleDistributor

Mints new NFTs to recipients.

Key Behavior:

  • Creates new tokens via safeMint

  • No withdrawal function (mints are permanent)

SimpleNoMintERC721MerkleDistributor

Distributes pre-existing NFTs.

Key Behavior:

  • Transfers NFTs held by contract

  • Owner can withdraw specific token IDs

  • Repurposes amount parameter as tokenId

Custom Extensions

CustomFeesNativeMerkleDistributor

Native token distributor with fee threshold logic.

Features:

  • Configurable feelessThreshold

  • Claims below threshold bypass fees

  • Modified claim flow for fee handling

NFTGatedMerkleDistributor

Claims gated by NFT ownership.

struct NFTGatedMerkleDistributorData {
    TokenTableMerkleDistributorData base;
    uint256 expiryTimestamp;
    uint256 nftTokenId;
}

Special Features:

  • Claims tied to NFT ownership

  • Delegate.xyz integration

  • Auto-recipient from NFT owner

πŸ’° Fee System

Overview

The fee system provides flexible fee collection for claims.

Components

     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚  Claim Request  β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Fee Collector Set? β”‚
    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
          β”‚       β”‚
      Yes β”‚       β”‚ No
          β”‚       β”‚
          β–Ό       β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚Calculate β”‚ β”‚  No     β”‚
    β”‚   Fee    β”‚ β”‚  Fee    β”‚
    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚    Fee Token?    β”‚
    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
          β”‚       β”‚
   Native β”‚       β”‚ ERC20
          β”‚       β”‚
          β–Ό       β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Deduct   β”‚ β”‚  Transfer   β”‚
    β”‚ from     β”‚ β”‚  from       β”‚
    β”‚ msg.valueβ”‚ β”‚  Payer      β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Configuration

  1. Fee Collector - Address that receives fees

  2. Fee Token - Native or ERC20 token for fees

  3. Fee Calculation - External ITTUFeeCollector interface

πŸ”’ Security

Access Control

Role
Permissions

Owner

Set parameters, withdraw tokens, configure extensions

Delegate

Claim on behalf of recipients

Users

Claim their allocated tokens

Security Features

  • Reentrancy Guards - All state-changing functions protected

  • Leaf Tracking - Prevents double claims

  • Time Windows - Enforced distribution periods

  • Proof Verification - Cryptographic claim validation

πŸ“‘ Events & Errors

Events

Event
Description

ClaimDelegateSet

Delegate address updated

Claimed

Successful token claim

Errors

Error
Condition
Selector

UnsupportedOperation

Operation not allowed

0x9ba6061b

TimeInactive

Outside claim window

0x0c143eb8

InvalidProof

Merkle proof invalid

0x09bde339

LeafUsed

Already claimed

0x0e4b0ab2

IncorrectFees

Fee amount mismatch

0x1669aa83

PreviousDeployerNextSignature Distributor

Last updated 2 days ago

Was this helpful?