@le7el/merkle_distributor
v0.1.12
Published
📦 A smart contract that distributes a balance of tokens according to a merkle root
Readme
@le7el/merkle_distributor
It's an adapted fork of @uniswap/merkle-distributor.
This version is adopted for web usage (instead of orginal NodeJS) and has the concept of "rounds". As change of round usually implies the change of a root hash, all unclaimed rewards from a previous round could be expired in a next round.
This version of merkle distributor also has admin controls to declare new rounds, withdraw an unclaimed tokens and pausing / unpausing of the claim process.
JS
Installation
npm install @le7el/merkle_distributorGetting started
Install packages
$ npm install --devInstall Hardhat
$ npm install --save-dev hardhatLaunch the local Ethereum client e.g. Ganache:
Testing
Install local ganache: npm install --global ganache
Run it in cli: ganache, you may need to change network_id for develop network in truffle-config.js
Run tests with truffle: yarn test
Integration
Run webpack development server: npx webpack serve --open or npm run webpack:watch
Check http://localhost:8080/ for Merkle proof generation and validation UX.
Implementation example entrypoints can be found here: src/index.ts and dist/index.html.
Verification
To try out Etherscan verification, you first need to deploy a contract to an Ethereum network that's supported by Etherscan, such as Rinkeby.
In this project, copy the .example file to a file named .secret, and then edit it to fill in the details. Enter your Etherscan API key, your Rinkeby node URL (eg from Infura), and the private key of the account which will send the deployment transaction. With a valid .secret file in place, first deploy your contract:
npx hardhat run --network live_rinkeby scripts/1_deploy_all.jsThen, copy the deployment address and paste it in to replace DEPLOYED_CONTRACT_ADDRESS in this command:
npx hardhat verify --network live_rinkeby DEPLOYED_CONTRACT_ADDRESS ...CONSTRUCTOR_ARGSDeployments
Rinkeby
MerkleDistributor (DAI token) deployed to: 0x1B1d03B59233243cb43844e930a6a1B181077cD9
