Casper with Jolie
# Step 1: Create and deploy a simple, smart contract
Installing Rust
![](https://i.imgur.com/sMIBBQn.png)
Installing Dependencies
![](https://i.imgur.com/SfgOT3V.png)
Compiling to WASM
![](https://i.imgur.com/aL0XsOA.png)
Test the Contract
![](https://i.imgur.com/9E9bT2T.png)
# Step 2: Complete one of the existing tutorials for writing smart contracts
## Writting the contract
After a lot step for prepare the sample contract to deploy, we need to compile it to WASM first and here is the result:
![](https://i.imgur.com/dxQozMf.png)
Now we will test the contract
First, deploy the local network
![](https://i.imgur.com/7yAdKJL.png)
Second, build the casper-client
![](https://i.imgur.com/wt3OyVE.png)
Finally, put deploy the contract
![](https://i.imgur.com/JP2cuE9.png)
Get depoy the contract
![](https://i.imgur.com/mD38vyn.png)
## Multi-Signature Tutorial
Building the Smart Contract
![](https://i.imgur.com/szjAXQr.png)
![](https://i.imgur.com/CvfoExa.png)
Testing the Client
This is part of result
Beginning of result
![](https://i.imgur.com/JqM8EA1.png)
End of result
![](https://i.imgur.com/GAzVOVA.png)
# Step 3: Demonstrate key management concepts by modifying the client in the Multi-Sig tutorial to address
**Scenario 3: signing transactions with multiple keys**
Insert demo code to package file
![](https://i.imgur.com/TbeGjPp.png)
Demo code:
```
const keyManager = require('./key-manager');
const TRANSFER_AMOUNT = process.env.TRANSFER_AMOUNT || 2500000000;
(async function () {
// Procedure:
// 1. Set mainAccount's weight to 3.
// 2. Set Keys Management Threshold to 3.
// 3. Set Deploy Threshold to 2.
// 4. Add first new key with weight 1 (first account).
// 5. Add second new key with weight 1 (second account).
// 6. Make a transfer from mainAccount using the new accounts.
// 7. Remove first account.
// 8. Remove second account.
let deploy;
// 0. Initial state of the account.
// There should be only one associated key (facuet) with weight 1.
// Deployment Threshold should be set to 1.
// Key Management Threshold should be set to 1.
let masterKey = keyManager.randomMasterKey();
let mainAccount = masterKey.deriveIndex(1);
let firstAccount = masterKey.deriveIndex(2);
let secondAccount = masterKey.deriveIndex(3);
console.log("\n0.1 Fund main account.\n");
await keyManager.fundAccount(mainAccount);
await keyManager.printAccount(mainAccount);
console.log("\n[x]0.2 Install Keys Manager contract");
deploy = keyManager.keys.buildContractInstallDeploy(mainAccount);
await keyManager.sendDeploy(deploy, [mainAccount]);
await keyManager.printAccount(mainAccount);
// 1. Add additional key with weight 1 .
console.log("\n1. Add additional key with weight 1.\n");
deploy = keyManager.keys.setKeyWeightDeploy(mainAccount, firstAccount, 1);
await keyManager.sendDeploy(deploy, [mainAccount]);
await keyManager.printAccount(mainAccount);
// 2. Set Keys Management Threshold to 2.
console.log("\n2. Set Keys Management Threshold to 2\n");
deploy = keyManager.keys.setKeyManagementThresholdDeploy(mainAccount, 2);
await keyManager.sendDeploy(deploy, [mainAccount]);
await keyManager.printAccount(mainAccount);
// 3. Make a transfer from faucet using the new accounts.
console.log("\n3. Make a transfer from faucet to secondAccount.\n");
deploy = keyManager.transferDeploy(mainAccount, secondAccount, TRANSFER_AMOUNT);
await keyManager.sendDeploy(deploy, [firstAccount]);
await keyManager.printAccount(mainAccount);
// 4. Add new key with weight 1.
console.log("\n4. Add new key with weight 1\n");
deploy = keyManager.keys.setKeyWeightDeploy(mainAccount, secondAccount, 1);
await keyManager.sendDeploy(deploy, [mainAccount, firstAccount]);
await keyManager.printAccount(mainAccount);
})();
```
Start the demo code:
Beginning of result
![](https://i.imgur.com/Pj4DICG.png)
End of result
![](https://i.imgur.com/S6Zzaqj.png)
# Step 4: Learn to transfer tokens
First, use the private key created at Deploy Contract step for import to Casper Wallet
Second, get the Faucet tool on Casper Portal
Finally, start to transfer the token
![](https://i.imgur.com/7NfnxuH.png)
---
![](https://i.imgur.com/7ZX3hof.png)
![](https://i.imgur.com/4RVedk8.png)
# Step 5: Learn to Delegate and Undelegate
Delegate completed successfully
![](https://i.imgur.com/wgSsapT.png)
Undelegate completed successfully
![](https://i.imgur.com/4Ehdj4q.png)