Staking Rewards Contract allows users to stake a token to a system and receive a reward.
This is the project main structure:
- contracts
- migrations
- config
- test
contracts directory contains smart contracts containing a system functionality.
- mock - directory contains ERC20 mock token smart contracts (staking and reward). They are used only when running tests - in this case mock tokens are deployed and used in unit tests. For testnet and mainnet pre-deployed token contracts are used (the addressed should be specified in .env file).
config directory contains configurations - addressed of pre-deployed staking and reward token contracts (for testnet and mainnet), infura URL and mnemonic.
test directory contains unit tests of the Staking Contract functions.
$ npm install
A local .env file should be created with environment variables. Here is a template:
STAKING_TOKEN_ADDRESS=<The address of deployed Staking Token Contract>
REWARD_TOKEN_ADDRESS=<The address of deployed Reward Token Contract>
INFURA_URL=<The URL of infura for the project>
MNEMONIC=<the user account mnemonic>
Run the following command to compile project smart contracts:
truffle compile
Run the following command to run unit tests on test env:
truffle test