This is a smart contract that allows for the distribution of tokens to a list of addresses. The contract is designed to be used with the Merkle Airdrop CLI tool/script.
Prerequisites
- Node.js (v14 or later)
- yarn (v1.22 or later)
- Hardhat (for smart contract deployment)
Installation
- Clone the repository
git clone https://github.com/your-repo/merkle-airdrop.git cd merkle-airdrop
2. Install the dependencies
```bash
yarn install
Running the Scripts
- Create a
eligible.csv
file in thedata
directory with the list of addresses and their corresponding token amounts. - Run the
generate
script to generate merkle tree data from theeligible.csv
file. This will be saved ineligible-packed.json
file.
yarn generate
- Run the script
yarn merkle
- The script will generate a
merkle.json
file in thedata
directory. This file contains the Merkle root and the list of addresses and token amounts.
Prerequisites
- Ensure you have set up environmental variables using the cli. Here's a guide on how to set up environmental variables using the CLI link. All the required ENV are listed in the
.env.example
file. - Ensure you have sufficient funds in the deployer account to deploy the contract.
Deployment Steps
- Compile the smart contract
yarn compile
- Deploy the token contract
npx hardhat ignition deploy ignition/modules/MyToken.ts --network <network>
- Update the
configs/config.ts
with the deployed token address. - Deploy the Merkle Airdrop contract
npx hardhat ignition deploy ignition/modules/MerkleAirdrop.ts --network <network>
- Update the
scripts/interaction.ts
file with the deployed Token and Merkle Airdrop contract address.
How to Generate Proofs
- Update
merkle.ts
with the address and amount you wish to generate proof for. - Run the
merkle
script using the command below.
yarn merkle
- Find the proof in the
data/proofs.json
. - Update the proof in the
scripts/interaction.ts
file. - Run the interaction script using the command below.
yarn interaction