Skip to content

Rahber-1/Airdrop_Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AirdropEngine & GoldToken Contract

This repository contains a set of Solidity smart contracts for the AirdropEngine and GoldToken contracts, built using the Foundry testing framework. The project is designed to enable secure and efficient token distribution through airdrops using Merkle Tree-based proofs and cryptographic signatures.

Table of Contents

Overview

The main components of this project are:

  1. AirdropEngine: A contract that allows the distribution of tokens to eligible users based on Merkle Tree proofs and cryptographic signatures. Users can claim tokens only if they are part of the airdrop list, and claims are validated with a Merkle root and signature verification.

  2. GoldToken: A custom ERC20 token used in the airdrop distribution. It represents the tokens that will be distributed through the AirdropEngine contract.

The AirdropEngine ensures secure and fair token distribution, while GoldToken handles the token balances and transfers.

Features

  • Merkle Tree-based Airdrops: Claims are validated using Merkle Tree proofs, ensuring only eligible users can claim tokens.
  • Signature-based Authentication: Claims are verified with a cryptographic signature, ensuring authenticity.
  • Reentrancy Protection: Users can only claim once per address to avoid reentrancy attacks.
  • Token Distribution: Allows for efficient and fair distribution of tokens to the community.
  • Admin Control: The contract owner can update the Merkle root for future airdrops.

Contracts

1. AirdropEngine.sol

The AirdropEngine contract is responsible for managing the airdrop process. It validates claims using Merkle proofs and checks the validity of the signature before transferring the tokens.

Functions:

  • claimTokens(address user, uint256 amount, bytes32[] proof, bytes signature): Allows a user to claim tokens if their proof and signature are valid.
  • getMerkleRoot(): Returns the current Merkle root for the airdrop.
  • updateMerkleRoot(bytes32 newRoot): Allows the owner to update the Merkle root for future airdrops (owner only).

2. GoldToken.sol

The GoldToken contract is a standard ERC20 token representing the tokens distributed in the airdrop.

Functions:

  • mint(address to, uint256 amount): Mints new tokens to a specified address.
  • transfer(address to, uint256 amount): Transfers tokens to a specified address.
  • balanceOf(address account): Returns the balance of tokens held by a specified address.

Installation

To get started, clone the repository and install the required dependencies.

git clone https://github.com/Rahber-1/Airdrop_Project.git
cd Airdrop_Project

Make sure you have Foundry installed. If you don’t have it, you can install it by following the instructions on the Foundry GitHub page.

Testing

The project includes a suite of tests that cover the primary functionalities of the AirdropEngine and GoldToken contracts.

To run the tests, use the following command:

forge test

This will compile the contracts and run the tests using the Foundry framework.

Test Cases Included:

  • testClaimTokens: Verifies that a user can successfully claim tokens with a valid Merkle proof and signature.
  • testInvalidMerkleProof: Ensures the contract reverts when an invalid Merkle proof is provided.
  • testAlreadyClaimed: Ensures users can only claim tokens once.
  • testInvalidSignature: Ensures that an invalid signature results in a revert.
  • testUpdateMerkleRoot: Verifies that the contract owner can update the Merkle root for future airdrops.
  • testContractBalanceAfterClaim: Ensures that the contract's balance is updated after a claim.
  • testInsufficientContractBalance: Tests that the contract reverts if it does not have enough tokens for a claim.

Usage

  1. Deploy the Contracts: Deploy the GoldToken and AirdropEngine contracts on your Ethereum-compatible blockchain.
  2. Generate Merkle Root: Generate a Merkle root for the list of eligible users.
  3. Update Merkle Root: Update the AirdropEngine contract with the generated Merkle root using the updateMerkleRoot function.
  4. Claim Tokens: Users can claim tokens by calling the claimTokens function and submitting their Merkle proof and a valid signature.
  5. Admin Control: The contract owner can update the Merkle root for future airdrops.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published