A simple contract for distributing ongoing rewards calculated offchain.
Rewards are periodically calculated offchain and a new Merkle tree containing the totalAmount
s for each account is produced. The calculated totalAmount
s amount for each account should strictly increase or stay the same with time.
Each period, the owner calls setMerkleRoot
and the new merkleRoot
and totalRewards
are set. This function also collects rewards tokens from the owner equal to the difference between currentTotalRewards
and the new totalRewards
.
Accounts can withdraw the difference between their totalAmount
and merkleRewards.withdrawn(account)
.
Note: The owner is completely trusted until ownership is revoked or all funds are claimed.
npm run compile
npm run test
Create a .env
file based on .env-sample
Start local node
npm run chain
Deploy to local node
npm run deploy:local
Deploy to Goerli
npm run goerli
Deploy to Mainnet
npm run mainnet
eslint
npm run eslint
prettier
npm run prettier
solhint
npm run solhint