This project is a Solidity-based smart contract built with the Foundry framework. It enables the secure and efficient distribution of tokens to multiple recipients in a single transaction. The contract utilizes cryptographic proofs to verify recipient eligibility, ensuring that only authorized participants can claim tokens. This approach is inspired by established airdrop mechanisms used in blockchain ecosystems.
Ensure you have the following installed:
-
Git: Install Git
-
Verify installation:
git --version
-
-
Foundry: Install Foundry
-
Verify installation:
forge --version
-
This guide assumes you're working with standard Foundry, not Foundry-ZKSync.
Clone the repository and install dependencies:
git clone https://github.com/hedy-kh/AirDrop-Project.git
make # or use "forge install && forge build" if you don't have make installed
To distribute tokens, we generate Merkle proofs for an array of recipient addresses. If you want to use the default addresses and proofs in this repository, skip to Deployment.
- Update the list of addresses in
GenerateInput.s.sol
. - Run the following command to generate the Merkle root and proofs:
Using make
:
make merkle
Or manually:
forge script script/Generateinput.s.sol:GenerateInput && forge script script/MakeMerkle.s.sol:MakeMerkle
- Retrieve the Merkle root from
script/target/output.json
and update:- The
ROOT
variable in theMakefile
(for zkSync deployments). - The
s_merkleRoot
inDeployMerkleAirdrop.s.sol
(for Ethereum/Anvil deployments).
- The
# Ensure you're using standard Foundry
foundryup
# Start a local Anvil node
make anvil
# Deploy the contracts
make deploy
foundryup
make anvil
make deploy
After deployment, copy the Airdrop Contract Address and Token Address, and paste them into the AIRDROP_ADDRESS
and TOKEN_ADDRESS
variables in the Makefile
.
make sign
Retrieve the generated signature and update Interact.s.sol
.
If you've changed the recipient addresses in the Merkle tree, also update the proof data from output.json
.
make claim
Verify the claim by checking the balance:
make balance
The default Anvil address (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
) will receive the airdropped tokens.
Run tests using Foundry:
foundryup
forge test
For zkSync compatibility:
make zktest # Runs: foundryup-zksync && forge test --zksync && foundryup
forge coverage
Estimate gas costs with:
forge snapshot
Results will be stored in .gas-snapshot
.
Ensure consistent formatting:
forge fmt
This project provides a secure and efficient way to distribute tokens using cryptographic proofs. By leveraging Foundry, ensure a robust testing and deployment process.