ETHPool smart contract implementation -- Based on the EIP-1973 spec: "Scalable Rewards" (https://eips.ethereum.org/EIPS/eip-1973)
Deployed and verified testnet contract located at: https://ropsten.etherscan.io/address/0xe624d2d9da2b5012352286911bb7f17c2f64f304
This ETHPool contract allows users to deposit ETH and receive rewards proportional to their deposits in the pool. Users must be able to take out their deposits along with their portion of rewards at any time. New rewards are deposited manually into the pool by the team using a contract function.
- Only the team members can deposit rewards.
- The team can deposit rewards at any time.
- Deposited rewards go to the pool of users, not to individual users.
- Users should be able to withdraw their deposits along with their share of rewards considering the time when they deposited. They should not get rewards for the ones distributed before their deposits.
-truffle
-ganache (for local deployment)
- Create a .env file in the project root with the key-values found in .env.sample
- Run
truffle deploy --network ropsten
- Run
truffle console --network ropsten
- Access the deployed contract instance:
Rewards.deployed().then(instance => instance)
- Try out the contract functions, for example:
Rewards.deployed().then(instance => instance.contributeToPool({ from: <your address here>, value: '500000000000000' }))
- Generate the Standard Json-Input file:
truffle run stdjsonin Rewards
- Upload the generated
Rewards-input.json
file to Etherscan's Verify and Publish tool
- Run
node ./scripts/query-contract.js
- Come up with a strategy to handle dust when dealing with fractional calculations
- Add thorough test coverage
- A real-life contract like this would need methods for the team members to withdraw the deposited funds to spend/invest in strategies that ultimately generate the rewards