Synthetix's StakingRewards contract translation written in Rust built to work on the Casper Blockchain.
- Implemented the StakingRewards contract.
- Implemented ERC20 contract version which uses
Casper dictionaries
andKey
's instead ofAccountHash
's. - Implemented the integration tests for the contracts.
- Implemented a bash script which facilitates the contracts deployment and testing on
Casper-testnet
.
Make sure wasm32-unknown-unknown
is installed.
$ make prepare
wasm-strip
helps reduce the compiled wasm contract's size. It can be found in the wabt
package.
$ sudo apt-get install wabt
$ cargo test -p libs
$ make build-contract
Test logic and smart contracts.
$ make test
Testing the contracts locally using TestContext
has its limitations.
In our case the runtime::get_blocktime()
will always return 0, and runtime::call_contract()
won't recognize the contract's hashes provided.
That's why we created a bash script that helps us test our contracts more easily on the Casper Testnet
.
The steps in order to test our contract's endpoints are the following:
- Install the nightly version of the compiler and Casper client.
$ rustup toolchain install nightly
$ cargo +nightly-2021-06-17 install casper-client
- Create keys for every contract deployer using
casper-client
.
$ casper-client keygen keys/staking_token
$ casper-client keygen keys/rewards_token
$ casper-client keygen keys/rewards_distribution
$ casper-client keygen keys/staking_rewards
- Connect
casper-signer
to https://testnet.cspr.live/ and import your created accounts. - For every account, visit https://testnet.cspr.live/tools/faucet and put the account's public key and click on
Request Tokens
. - Give permission to the testnet script.
$ chmod +x testnet.sh
- Execute the following command to get the script's syntax.
$ ./testnet.sh syntax
- After calling a deploy (transaction), you will get a
deploy hash
that in your terminal. To check the deploy status, execute the following.
$ ./testnet.sh check_status <DEPLOY_HASH>
The result will be written in the deploy_status.json
file.