This is an implementation of Uniswap's merkle payout contract and is built using hardhat. The original implementation can be found here
This is a sample contract which has been deployed on rinkeby
This merkle contract supports
- deploying on
mainnet
/rinkeby
- on deploy
funder
token
merkleRoot
funder
: the address who deposts and can reclaim fundstoken
: ERC20 token in which the payouts should happenmerkleRoot
: generated merkle root of the distributionhasClaimed
: check if an address has a pending claim
claim
: allows address to make a claim against the contractbatchClaim
: invoked byfunder
to trigger all pending claimsreclaimFunds
: invoked byfunder
and allowedtoken
to be sent back tofunder
ReclaimFunds
: emitted whenfunder
invokesreclaimFunds
FundsClaimed
: emitted whenaddress
succesfully invokesclaim
BatchClaimTriggered
: emitted whenfunder
succesfully invokesbatchClaim
-
Create an
.env
file and fill outINFURA_ID
: Infura ID for deploying contractDEPLOYER_PRIVATE_KEY
: address which deploys the contractETHERSCAN_API_KEY
: API key for etherscan verificationTOKEN
: Access token for theingest_merkle_claim_to_clr_match
APIGRANT_PAYOUT_PK
: Grant payout primary keyAPI_BASE_URL
: Base backend API URL (http://localhost:8000
orhttps://gitcoin.co
)
-
Update
input.ts
parametersPayoutConfig
PayoutDistribution[]
-
Update
verify.ts
parametertoken
merkleRoot
funder
-
Deploy contract
yarn deploy:rinkeby # deploy on rinkeby yarn deploy:mainnet # deploy on mainnet
-
Verify contract on etherscan
# rinkeby yarn hardhat verify --constructor-args verify.js --network rinkeby <CONTRACT_ADDRESS> # mainnet yarn hardhat verify --constructor-args verify.js --network mainnet <CONTRACT_ADDRESS>
-
The claims object would be generated and stored in
scripts/output.json
. This would be required for an address to make a claim Note: To make a claim against via etherscan, the claim object would be of the following format[2,'0x5cdb35fADB8262A3f88863254c870c2e6A848CcA','0x4563918244f40000',['0x025ddd38f5815f027203629fc384e2a7beb453a112c2de03feb75dca73aef3bf','0xc1d74d73190dcdd156b817d78d3459ecd5efac2345c34fa48ad52d2ae11dc526','0x2bb06b1200f1a5d9c3d252ec853852c5042118c7fa74781e510ed334add6a1f2','0x2107e84fe9e2588768a806612070bc0c2095c08e70af311cad5ae5c2c0fa27a4']]
-
Ingest merkle claims in the backend:
yarn ingest_merkle_claims
Any time you make changes to the contract/ deploy scripts. Ensure these steps are run before raising a PR to make changes
hardhat clean # clean artifacts
hardhat compile # compile contract
yarn lint # eslint
yarn prettier # prettier
yarn test # test
yarn coverage # coverage report
Coverage report is built using solidity-coverage plugin.
alias chrome="open -a 'Google Chrome'"
yarn coverage
chrome coverage/index.html