Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🪂 Airdrop Token System with EIP-712 & Merkle Tree Whitelisting

A secure, gas-optimized airdrop smart contract built with Solidity that uses EIP-712 for off-chain signature verification and Merkle Trees for scalable whitelisting.


📸 Demo Flow (Architecture)

Airdrop Flow Diagram


📦 Features

  • ✅ EIP-712 typed structured signatures for off-chain whitelisting
  • 🌲 Merkle Tree proof verification for scalable claims (O(log N))
  • 🔒 Signature replay protection
  • 🔄 One-time claim enforcement
  • ⛽ Gas-optimized design

📚 Tech Stack

  • Solidity for smart contracts

  • Foundry for testing and deployment

  • Merkle Tree JS utilities for generating proofs

  • EIP-712 Typed Data Signatures


📂 Project Structure

├── contracts
│   └── Airdrop.sol
├── scripts
│   └── DeployMerkleAirDrop.s.sol / Interact.s.sol
├── test
│   └── MerkleAirDrop.t.sol
├── assets
│   └── airdrop.png
└── README.md

🚀 How It Works

  1. Off-chain, a list of eligible addresses and airdrop amounts is created.
  2. A Merkle Tree is generated using this list.
  3. Each user signs a claim message using EIP-712.
  4. The user sends a transaction with:
    • Their address and claim amount
    • EIP-712 signature
    • Merkle proof
  5. The smart contract verifies:
    • The Merkle proof is valid
    • The signature matches the typed data
    • The user hasn’t claimed before
  6. Tokens are transferred securely 🎉

🔧 Setup Instructions

  1. Clone the repo:

    git clone https://github.com/DakshMane/AirDropContract
    cd merkle-airdrop
  2. Install dependencies:

    npm install
  3. Compile contracts:

    forge build
  4. Run tests:

         forge test

📄 Example Claim Function

function claim(address account, uint256 amount, bytes calldata sig, bytes32[] calldata merkleProof) external {
    require(!claimed[account], "Already claimed");

    // Verify Merkle proof
    bytes32 node = keccak256(abi.encodePacked(account, amount));
    require(MerkleProof.verify(merkleProof, merkleRoot, node), "Invalid proof");

    // Verify EIP-712 signature
    require(verifySignature(account, amount, sig), "Invalid signature");

    claimed[account] = true;
    token.transfer(account, amount);
}

🤝 Contributing

PRs and feedback welcome! If you found this useful or learned something, feel free to give it a ⭐


🧠 Learn More


📬 Contact

Made with ❤️ by Daksh Mane
Open to feedback, collaborations, and Web3 conversations!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages