---
# System prepended metadata

title: Get started with Casper

---

# Get started with Casper

### 1. Create and deploy a simple, smart contract with cargo casper and cargo test

Create a project called project1 with cargo casper

![](https://i.imgur.com/GrNVhu7.png)

Once the project is created move to tests folder and run cargo test

![](https://i.imgur.com/XwkJrND.png)

The final result shows the successful creation and test of a simple contract.

![](https://i.imgur.com/zfeYgZ9.png)

### 2. Complete one of the existing tutorials for writing smart contracts

I completed the Multi-signature tutorial for this task.

Clone the tutorial and build smart contract

![](https://i.imgur.com/xdoKvp8.png)



Set up Local Network and view the Network State

![](https://i.imgur.com/JJ7lKUd.png)


Setting up the client

![](https://i.imgur.com/Y9NU8BO.png)


Testing the client

![](https://i.imgur.com/nh33T07.png)

Final State

![](https://i.imgur.com/bMQYq05.png)


### 3. Demonstrate key management concepts by modifying the client in the Multi-Sig tutorial to address one of the additional scenarios

Scenario Two - deploying with special keys

scenario-two.js code

```javascript
const keyManager = require('./key-manager');
const TRANSFER_AMOUNT = process.env.TRANSFER_AMOUNT || 2500000000;

(async function() {
    // In this example, I am implementing scenario 2
    // There are two keys main (which can do both deployment and key management)
    // and secondary which can only do deployment but not key management

    // To achive the task, we will:
    // 1. Set mainAccount's weight to 2.
    // 2. Set Keys Management Threshold to 2.
    // 3. Set Deploy Threshold to 1.
    // 4. Add new key with weight 1 (secondary account).
    // 5. Make a transfer using secondary account. (should succeed)
    // 6. Add new key using secondary account. (should fail)

    let deploy;

    // init

    let masterKey = keyManager.randomMasterKey();
    let mainAccount = masterKey.deriveIndex(1);// Main Account
    let secondaryAccount = masterKey.deriveIndex(2);//Secondary Account
    let testAccount = masterKey.deriveIndex(3);// Test account

    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. Set mainAccount's weight to 2
    console.log("\n1. Set faucet's weight to 2\n");
    deploy = keyManager.keys.setKeyWeightDeploy(mainAccount, mainAccount, 2);
    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. Set Deploy Threshold to 1.
    console.log("\n3. Set Deploy Threshold to 1.\n");
    deploy = keyManager.keys.setDeploymentThresholdDeploy(mainAccount, 1);
    await keyManager.sendDeploy(deploy, [mainAccount]);
    await keyManager.printAccount(mainAccount);
    
    // 4. Add secondary key with weight 1 which can only deploy.
    console.log("\n4. Add secondary key with weight 1.\n");
    deploy = keyManager.keys.setKeyWeightDeploy(mainAccount, secondaryAccount, 1);
    await keyManager.sendDeploy(deploy, [mainAccount]);
    await keyManager.printAccount(mainAccount);

    // 6. Make a transfer from faucet using the secondary account.
    console.log("\n6. Make a transfer from faucet using the secondary account.\n");
    deploy = keyManager.transferDeploy(mainAccount, secondaryAccount, TRANSFER_AMOUNT);
    await keyManager.sendDeploy(deploy, [secondaryAccount]);
    await keyManager.printAccount(mainAccount);

    // 7. Add test key with weight 1 using secondary account.
    console.log("\n7. Add first new key with weight 1 using the secondary account. Should Fail\n");
    deploy = keyManager.keys.setKeyWeightDeploy(mainAccount, testAccount, 1);
    await keyManager.sendDeploy(deploy, [secondaryAccount]);
    await keyManager.printAccount(mainAccount);


})();
```

![](https://i.imgur.com/3jrYYJE.png)

npm run start:two

![](https://i.imgur.com/MyRHgK0.png)

Secondary key can only perform deployment but not key management.

6. Make a transfer from faucet using the secondary account. (Successful)

![](https://i.imgur.com/30NTeN0.png)

7. Add test key with weight 1 using secondary account. (Failure)

![](https://i.imgur.com/yP9WTLk.png)


### 4. Learn to transfer tokens to an account on the Casper Testnet. 

A Transfer of 3 CSPR from one account to another.

![](https://i.imgur.com/Y7y5CXx.png)

Check Deployment Status using deploy_hash

![](https://i.imgur.com/ShX7kW9.png)

Get State Root Hash using block_hash

![](https://i.imgur.com/14dpWcg.png)

Query the Source Account using state root hash

![](https://i.imgur.com/yLbC97G.png)

Query the Target Account using state root hash

![](https://i.imgur.com/80FAP11.png)

Query the source and target account balances one by one

![](https://i.imgur.com/AhIZlqA.png)

Query full transfer details

![](https://i.imgur.com/19xHBuz.png)

Testenet Explorer

Source Account

https://testnet.cspr.live/account/01d722236475bb58a4b25af13b0b861fd5f12fe9767e67562393bf8a2cbf65e34b

Target Account

https://testnet.cspr.live/account/01bda75a3e3dc96673bd315f35f3834a9319f44c9cb6785d2e482a11b54bab6168

Deploy Hash

https://testnet.cspr.live/deploy/b0fe96be82cf8af90289babb54606459a495227cad2e185c1c667975c9bb1810

### 5. Learn to Delegate and Undelegate on the Casper Testnet. 

Delegating 100 CSPR on Casper Testnet

Sign the transaction

![](https://i.imgur.com/35DHiLM.png)

100 CSPR staked

![](https://i.imgur.com/f8Tb2NO.png)

Staking Rewards after 4+ hours of staking

![](https://i.imgur.com/PLAfHGi.png)

Undelegate 100 CSPR + rewards

![](https://i.imgur.com/DKbRzqJ.png)

Undelegated 100.08 CSPR

![](https://i.imgur.com/pGDgAT9.png)


Account Status 24 hours after undelegating

![](https://i.imgur.com/vKxXQkL.png)





