Skip to content

TheArcadiaGroup/casper-staking-rewards-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Casper Implementation of Synthetix - StakingRewards contract

Synthetix's StakingRewards contract translation written in Rust built to work on the Casper Blockchain.

Done

  • Implemented the StakingRewards contract.
  • Implemented ERC20 contract version which uses Casper dictionaries and Key's instead of AccountHash's.
  • Implemented the integration tests for the contracts.
  • Implemented a bash script which facilitates the contracts deployment and testing on Casper-testnet.

Install compilation target

Make sure wasm32-unknown-unknown is installed.

$ make prepare

Install wasm-strip

wasm-strip helps reduce the compiled wasm contract's size. It can be found in the wabt package.

$ sudo apt-get install wabt

Test Math Library

$ cargo test -p libs

Build contracts

$ make build-contract

Test contracts locally

Test logic and smart contracts.

$ make test

Test contracts on casper-testnet

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:

  1. Install the nightly version of the compiler and Casper client.
$ rustup toolchain install nightly
$ cargo +nightly-2021-06-17 install casper-client
  1. 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
  1. Connect casper-signer to https://testnet.cspr.live/ and import your created accounts.
  2. For every account, visit https://testnet.cspr.live/tools/faucet and put the account's public key and click on Request Tokens.
  3. Give permission to the testnet script.
$ chmod +x testnet.sh
  1. Execute the following command to get the script's syntax.
$ ./testnet.sh syntax
  1. 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.

About

StakingRewards implementation on Casper blockchain using Rust.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published