- Installing rust, cargo-casper with rust package manager
- Create the project which I named 1-simple-smart-contract
- Compile contract with WebAssembly and build it
cd contract
rustup install $(cat rust-toolchain)
rustup target add --toolchain $(cat rust-toolchain) wasm32-unknown-unknown
cargo build --release
- Test the contract.
- Deploy a simple contract
I choose "A Counter Contract Tutorial".
- Check faucet account:
nctl-view-faucet-account
- Create local network and running node:
nctl-assets-setup && nctl-start
- Deploy counter contract and checking it state:
- The counter is currently set to 1
- After increment the counter again, the counter is set to 2.
3. Demonstrate key management concepts by modifying the client in the Multi-Sig tutorial to address one of the additional scenarios.
- First clone the keys management project: /~https://github.com/casper-ecosystem/keys-manager
- Create .env and run npm install
- Create an extension name "scenario-concept.js":
const keyManager = require('./key-manager');
(async function () {
// 1. Weight of `fullAccount` to 2
// 2. Key Management Threshold to 2
// 3. Deploy Threshold to 1
// 4. First new key with weight 1 (deploy key)
let deploy;
// 0. Initial state of the account.
// There should be only one associated key (faucet) with weight 1.
// Deployment Threshold should be set to 1.
// Key Management Threshold should be set to 1.
let masterKey = keyManager.randomMasterKey();
let fullAccount = masterKey.deriveIndex(1); // deployment and management
let deployAccount = masterKey.deriveIndex(2); // only for deployment
console.log("\n0.1 Fund main account.\n");
await keyManager.fundAccount(fullAccount);
await keyManager.printAccount(fullAccount);
console.log("\n[x]0.2 Install Keys Manager contract");
deploy = keyManager.keys.buildContractInstallDeploy(fullAccount);
await keyManager.sendDeploy(deploy, [fullAccount]);
await keyManager.printAccount(fullAccount);
// 1. Set fullAccount's weight to 2
console.log("\n1. Set faucet's weight to 2\n");
deploy = keyManager.keys.setKeyWeightDeploy(fullAccount, fullAccount, 2);
await keyManager.sendDeploy(deploy, [fullAccount]);
await keyManager.printAccount(fullAccount);
// 2. Set Keys Management Threshold to 2.
console.log("\n2. Set Keys Management Threshold to 2\n");
deploy = keyManager.keys.setKeyManagementThresholdDeploy(fullAccount, 2);
await keyManager.sendDeploy(deploy, [fullAccount]);
await keyManager.printAccount(fullAccount);
// 3. Set Deploy Threshold to 1.
console.log("\n3. Set Deploy Threshold to 1.\n");
deploy = keyManager.keys.setDeploymentThresholdDeploy(fullAccount, 1);
await keyManager.sendDeploy(deploy, [fullAccount]);
await keyManager.printAccount(fullAccount);
// 4. Add first new key with weight 1 (first account).
console.log("\n4. Add first new key with weight 1.\n");
deploy = keyManager.keys.setKeyWeightDeploy(fullAccount, deployAccount, 1);
await keyManager.sendDeploy(deploy, [fullAccount]);
await keyManager.printAccount(fullAccount);
})();
And add scripts in package.json.
start:scenario-concept": "node -r dotenv/config ./src/scenario-concept.js"
- Then run command:
npm run start:scenario-concept
- First create casper account testnet in https://testnet.cspr.live/
- Then transfer CSPR to account
- Check balance account again
My testnet account: https://testnet.cspr.live/account/018375a8c5a3e58d257c07119269e560a1df2755c519de6a5ba136ead73ac23d11
- To transfer CSPR from account to another, go to https://testnet.cspr.live/transfer and make a transfer action
- Transfer logs: https://testnet.cspr.live/deploy/a605d2ee5f5ae8bbeb72b7de24ee49aa42956f6efb32a3507f3def59bfaff46c
- To delegate go to and choose a validator then sign: https://testnet.cspr.live/delegate-stake.
- To undelegate go to and choose a validator then sign: https://testnet.cspr.live/undelegate-stake.