### 1. Create and deploy a simple, smart contract with cargo casper and cargo test - Installed all prerequisites following this guide: https://docs.casperlabs.io/en/latest/dapp-dev-guide/setup-of-rust-contract-sdk.html - Created a first sample project to see how it works ![](https://i.imgur.com/IZIi2Xa.png) - Set up a local casper network following this guide: https://docs.casperlabs.io/en/latest/dapp-dev-guide/setup-nctl.html ![](https://i.imgur.com/SJ62JrJ.png) ![](https://i.imgur.com/eajW0PB.png) ### 2. Complete one of the existing tutorials for writing smart contracts: Multi-Signature Tutorial - Built the contract ![](https://i.imgur.com/A31aldT.png) - Set up the network ![](https://i.imgur.com/BYJAW6b.png) - View faucet account ![](https://i.imgur.com/FiaG5O7.png) - Run the tests *Beggining of the test log* ![](https://i.imgur.com/5TpfZrc.png) *End of the test log* ![](https://i.imgur.com/xd4oSFR.png) ### 3. Demonstrate key management concepts by modifying the client in the Multi-Sig tutorial to address one of the additional scenarios - Created an extension for Scenario 2 > In this example, you have two keys. One key can only perform deployments, while the second key can perform key management and deployments. The key with account address a1 can deploy and make account changes, but the second key with account address b2 can only deploy. ``` 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); })(); ``` *Beginning of test log* ![](https://i.imgur.com/mZM9ZuK.png) *End of test log* ![](https://i.imgur.com/K4ufWrb.png) ### 4. Learn to transfer tokens to an account on the Casper Testnet. - Created a testnet wallet and request funds to the faucet: https://testnet.cspr.live/deploy/f37a10f52153fcf9379e4d0cc7d4fde07b22c632c04a14ed90578eb6a2b5f63b - Installed the `casper-client` ![](https://i.imgur.com/b6HXAOd.png) - Check the balance of my account ``` casper-client query-state --id 5 --node-address http://65.21.237.153:7777/rpc --state-root-hash a508054191cf46d8fd18c7e36ca06d4184732d00641edc6f58f5add88c121826 --key 0144940b665d83ac8db44085ed3e7d041d5245c7c3f1b4e5386999a12441980f5f ``` ``` { "id": 5, "jsonrpc": "2.0", "result": { "api_version": "1.3.2", "merkle_proof": "[18832 hex chars]", "stored_value": { "Account": { "account_hash": "account-hash-24e76a14d366e21fb9d7df2f5ff91ab817b23f10fcf0c5ac206d83a6dca904fb", "action_thresholds": { "deployment": 1, "key_management": 1 }, "associated_keys": [ { "account_hash": "account-hash-24e76a14d366e21fb9d7df2f5ff91ab817b23f10fcf0c5ac206d83a6dca904fb", "weight": 1 } ], "main_purse": "uref-01585756b8a08b7583a8e9515834aa6ce6b116c7074a76769cdb74855ffedad8-007", "named_keys": [] } } } } ``` ``` casper-client get-balance --id 6 --node-address http://65.21.237.153:7777/rpc --state-root-hash a508054191cf46d8fd18c7e36ca06d4184732d00641edc6f58f5add88c121826 --purse-uref uref-01585756b8a08b7583a8e9515834aa6ce6b116c7074a76769cdb74855ffedad8-007 ``` ``` { "id": 6, "jsonrpc": "2.0", "result": { "api_version": "1.3.2", "balance_value": "1000000000000", "merkle_proof": "[20262 hex chars]" } } ``` ![](https://i.imgur.com/0hwXHSg.png) - Transfer of an amount of 2.5 CSPR: https://testnet.cspr.live/deploy/f3cf26462c9da272568cf8d15505005a8d74d75d38a150f12213f13271ab80e4 ![](https://i.imgur.com/IUCpXnz.png) ![](https://i.imgur.com/fxPRmAi.png) ``` casper-client get-balance --id 6 --node-address http://65.21.237.153:7777/rpc --state-root-hash 3e54ceafee9862fe7a24284b51895d44abd9e45de75fe41a9cca77b99a712773 --purse-uref uref-01585756b8a08b7583a8e9515834aa6ce6b116c7074a76769cdb74855ffedad8-007 ``` ``` { "id": 6, "jsonrpc": "2.0", "result": { "api_version": "1.3.2", "balance_value": "997499990000", "merkle_proof": "[20262 hex chars]" } } ``` ### 5. Learn to Delegate and Undelegate on the Casper Testnet. - Delegate the maximum amount of tokens to `0144e35abc4886168a53338539a8a3649ab1257d9f0c235ce38961624a025d40dd`: https://testnet.cspr.live/deploy/c59d36c5dc0d333119b6bf527516bec7757e7f1037228ce628c126cea96a64b2 ![](https://i.imgur.com/xzMQIBN.png) ![](https://i.imgur.com/meG6jbF.png) - Undelegate 200 CSPR: https://testnet.cspr.live/deploy/3559c0076ecf848e73bf8911a1ae7b12227ed697fecfc62612b2986c74e5f3ad ![](https://i.imgur.com/SKM8Urs.png) ![](https://i.imgur.com/zLH82aO.png)