1.1.1 • Published 2 years ago
@sonne-finance/merkle-airdrop v1.1.1
Merkle Airdrop
This repository contains the contracts for the Merkle Airdrop. The contracts are written in Solidity and are tested using Hardhat.
Overview
The Merkle Airdrop contract allows for airdrops to be done in a trustless manner. The contract is initialized with a Merkle root, which is a hash of all the airdrop recipients and their respective amounts. The contract then allows anyone to claim their airdrop by providing a Merkle proof that they are in the airdrop.
Building
Install Prerequisites
npm install
Run Tests
npm run test
Usage
npm i @sonne-finance/merkle-airdrop
### Setting the root for the airdrop
import { ethers } from 'ethers';
import { Airdrop, sendTx, setMerkleRoot } from '@sonne-finance/merkle-airdrop';
const setRoot = async () => {
const data: Airdrop[] = [];
const AIRDROP_ADDRESS = '';
const WALLET: ethers.Wallet;
const tx = await setMerkleRoot(data, { airdropAddress: AIRDROP_ADDRESS });
await sendTx(tx, WALLET);
};
Claiming Airdrop
import { ethers } from 'ethers';
import { Airdrop, claim, sendTx } from '../client';
const claimAirdrop = async () => {
const data: Airdrop[] = [];
const AIRDROP_ADDRESS = '';
const WALLET: ethers.Wallet;
const tx = await claim(data, WALLET.address, { airdropAddress: AIRDROP_ADDRESS });
await sendTx(tx, WALLET);
};