---
# System prepended metadata

title: '**Task 1: Create and deploy a simple, smart contract with cargo casper and cargo test**'

---

**Get started with Casper**

---
# **Task 1: Create and deploy a simple, smart contract with cargo casper and cargo test**

## Getting Started

After install all prerequired and build the contract. The final step is test the contract.

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

## Write smart contracts in WebAssembly (WASM).

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

## Deploying Contracts

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

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

> **Multi-Signature Tutorial**

## Building the Smart Contract

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

## Setting up a local Casper Network

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

## Faucet account details 

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

## Testing the Client

Full result is below:

```
(env) root@ubuntu-vm:~/keys-manager/client# npm run start:atomic

> keys-manager@1.0.0 start:atomic
> node -r dotenv/config ./src/scenario-atomic.js


0.1 Fund main account.

Signed by: account-hash-253c76033edf1b813ab088e6fa5c3e95c71bef8299e38e3187b873b7837075e0
Deploy hash: f6dc74f90a9273309e722e1232e5fa943aba768fa7016dd38b089b8b0e1d50bf
Deploy result:
{
  deploy: {
    hash: 'f6dc74f90a9273309e722e1232e5fa943aba768fa7016dd38b089b8b0e1d50bf',
    header: {
      account: '01d70ad373c868b039da5fbec03d4ec6f8f961d96fb27d90360d109eae80eef26d',
      timestamp: '2021-09-25T19:17:55.531Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: 'e051e979ffb4eabb169af2359390950a685b5a0b63fdac5e3c64ce78fc4f4057',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { Transfer: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
  namedKeys: [],
  mainPurse: 'uref-c2d7a501978e85ee3f681988698813b6ad36032a62457abde0e3c0ad866d236b-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
      weight: 1
    }
  ],
  actionThresholds: { deployment: 1, keyManagement: 1 }
}

[x]0.2 Install Keys Manager contract
Signed by: account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8
Deploy hash: deffd5ee0daea5284121e4c276fa05be3b9e29d4feb4e199ad2616140cccdb85
Deploy result:
{
  deploy: {
    hash: 'deffd5ee0daea5284121e4c276fa05be3b9e29d4feb4e199ad2616140cccdb85',
    header: {
      account: '0202565899bab8f73265f51af616720988c2d677a0711dd70978754bd26b3b540f09',
      timestamp: '2021-09-25T19:18:59.701Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: '8b75c87f0c5c33503df86050553e6a490fdee8d5154d9eececdc7c22618217c8',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { ModuleBytes: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-00c9336cc065e77df76827cb56cd59cd10ab723020b85ad893133397df6e655f'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-2cc3780a21e634a3567f6c25668c27eb1b486b08b4bd9188b3e9d9cf0d88799b-007'
    }
  ],
  mainPurse: 'uref-c2d7a501978e85ee3f681988698813b6ad36032a62457abde0e3c0ad866d236b-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
      weight: 1
    }
  ],
  actionThresholds: { deployment: 1, keyManagement: 1 }
}

1. Set faucet's weight to 3

Signed by: account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8
Deploy hash: caf107f32e415dbc7de6fd5e1084a0f60d596561a09e35e3bd06efff6c5f23fa
Deploy result:
{
  deploy: {
    hash: 'caf107f32e415dbc7de6fd5e1084a0f60d596561a09e35e3bd06efff6c5f23fa',
    header: {
      account: '0202565899bab8f73265f51af616720988c2d677a0711dd70978754bd26b3b540f09',
      timestamp: '2021-09-25T19:20:05.413Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: 'b0ee3ab6888cf58af5754bae7ed3716510fc8148e9edada41d9e7bd6c43caf08',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { StoredContractByName: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-00c9336cc065e77df76827cb56cd59cd10ab723020b85ad893133397df6e655f'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-2cc3780a21e634a3567f6c25668c27eb1b486b08b4bd9188b3e9d9cf0d88799b-007'
    }
  ],
  mainPurse: 'uref-c2d7a501978e85ee3f681988698813b6ad36032a62457abde0e3c0ad866d236b-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
      weight: 3
    }
  ],
  actionThresholds: { deployment: 1, keyManagement: 1 }
}

2. Set Keys Management Threshold to 3

Signed by: account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8
Deploy hash: e1d655ef280d19b474e1cdc3d8f8d928048386a94aa83d90b34d4f1809d2343f
Deploy result:
{
  deploy: {
    hash: 'e1d655ef280d19b474e1cdc3d8f8d928048386a94aa83d90b34d4f1809d2343f',
    header: {
      account: '0202565899bab8f73265f51af616720988c2d677a0711dd70978754bd26b3b540f09',
      timestamp: '2021-09-25T19:21:11.542Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: '3f3394304ff22fe422511e62eed631bc501385f67fdd1fe71891f7d375550324',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { StoredContractByName: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-00c9336cc065e77df76827cb56cd59cd10ab723020b85ad893133397df6e655f'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-2cc3780a21e634a3567f6c25668c27eb1b486b08b4bd9188b3e9d9cf0d88799b-007'
    }
  ],
  mainPurse: 'uref-c2d7a501978e85ee3f681988698813b6ad36032a62457abde0e3c0ad866d236b-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
      weight: 3
    }
  ],
  actionThresholds: { deployment: 1, keyManagement: 3 }
}

3. Set Deploy Threshold to 2.

Signed by: account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8
Deploy hash: 2b1a017e4d59b4b737a5e01065f2d6835bc4ef2b0797e6b92c35da185146d7fe
Deploy result:
{
  deploy: {
    hash: '2b1a017e4d59b4b737a5e01065f2d6835bc4ef2b0797e6b92c35da185146d7fe',
    header: {
      account: '0202565899bab8f73265f51af616720988c2d677a0711dd70978754bd26b3b540f09',
      timestamp: '2021-09-25T19:22:16.477Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: '609e820d1eb41cd0fe90e6c5c4cf179afd2c9d9ba19bb0f21ca310a85450f228',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { StoredContractByName: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-00c9336cc065e77df76827cb56cd59cd10ab723020b85ad893133397df6e655f'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-2cc3780a21e634a3567f6c25668c27eb1b486b08b4bd9188b3e9d9cf0d88799b-007'
    }
  ],
  mainPurse: 'uref-c2d7a501978e85ee3f681988698813b6ad36032a62457abde0e3c0ad866d236b-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
      weight: 3
    }
  ],
  actionThresholds: { deployment: 2, keyManagement: 3 }
}

4. Add first new key with weight 1.

Signed by: account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8
Deploy hash: b66fee3e6311a03ab9cd818bd5704f8300db08e11de5fdbbeffb304783f9b4de
Deploy result:
{
  deploy: {
    hash: 'b66fee3e6311a03ab9cd818bd5704f8300db08e11de5fdbbeffb304783f9b4de',
    header: {
      account: '0202565899bab8f73265f51af616720988c2d677a0711dd70978754bd26b3b540f09',
      timestamp: '2021-09-25T19:23:22.457Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: 'bdc4655d4142049ab38dd7badadb602198b01a88f35560fd161d88eec35f226c',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { StoredContractByName: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-00c9336cc065e77df76827cb56cd59cd10ab723020b85ad893133397df6e655f'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-2cc3780a21e634a3567f6c25668c27eb1b486b08b4bd9188b3e9d9cf0d88799b-007'
    }
  ],
  mainPurse: 'uref-c2d7a501978e85ee3f681988698813b6ad36032a62457abde0e3c0ad866d236b-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
      weight: 3
    },
    {
      accountHash: 'account-hash-7714a5d2fed6056eaf5c16b93819637b8cd84c944ad45e896646343f32cc4e79',
      weight: 1
    }
  ],
  actionThresholds: { deployment: 2, keyManagement: 3 }
}

5. Add second new key with weight 1.

Signed by: account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8
Deploy hash: 75e2efa142fbd749bbaeed2fd3eb691a9ddfd725013e77b0a7ad2a1960fe3b5d
Deploy result:
{
  deploy: {
    hash: '75e2efa142fbd749bbaeed2fd3eb691a9ddfd725013e77b0a7ad2a1960fe3b5d',
    header: {
      account: '0202565899bab8f73265f51af616720988c2d677a0711dd70978754bd26b3b540f09',
      timestamp: '2021-09-25T19:24:27.311Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: '59dd3c8807141054993bd7b9f3273ce0df9674f7e31483cd31497560efdd6b81',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { StoredContractByName: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-00c9336cc065e77df76827cb56cd59cd10ab723020b85ad893133397df6e655f'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-2cc3780a21e634a3567f6c25668c27eb1b486b08b4bd9188b3e9d9cf0d88799b-007'
    }
  ],
  mainPurse: 'uref-c2d7a501978e85ee3f681988698813b6ad36032a62457abde0e3c0ad866d236b-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
      weight: 3
    },
    {
      accountHash: 'account-hash-7714a5d2fed6056eaf5c16b93819637b8cd84c944ad45e896646343f32cc4e79',
      weight: 1
    },
    {
      accountHash: 'account-hash-a30a7d66c2ff5b5bfcb05a76913089df058aa947732870ae37725c21b5539414',
      weight: 1
    }
  ],
  actionThresholds: { deployment: 2, keyManagement: 3 }
}

6. Make a transfer from faucet using the new accounts.

Signed by: account-hash-7714a5d2fed6056eaf5c16b93819637b8cd84c944ad45e896646343f32cc4e79
Signed by: account-hash-a30a7d66c2ff5b5bfcb05a76913089df058aa947732870ae37725c21b5539414
Deploy hash: 0dc353125025f61aba21597309b98703e29d615b862687786b1b6f1311e8de3e
Deploy result:
{
  deploy: {
    hash: '0dc353125025f61aba21597309b98703e29d615b862687786b1b6f1311e8de3e',
    header: {
      account: '0202565899bab8f73265f51af616720988c2d677a0711dd70978754bd26b3b540f09',
      timestamp: '2021-09-25T19:25:33.266Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: '0ed84a8caa4cb4092fd822404e7173f871baa45c4f8d3521b3c7837dfae079ee',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { Transfer: [Object] },
    approvals: [ [Object], [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-00c9336cc065e77df76827cb56cd59cd10ab723020b85ad893133397df6e655f'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-2cc3780a21e634a3567f6c25668c27eb1b486b08b4bd9188b3e9d9cf0d88799b-007'
    }
  ],
  mainPurse: 'uref-c2d7a501978e85ee3f681988698813b6ad36032a62457abde0e3c0ad866d236b-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
      weight: 3
    },
    {
      accountHash: 'account-hash-7714a5d2fed6056eaf5c16b93819637b8cd84c944ad45e896646343f32cc4e79',
      weight: 1
    },
    {
      accountHash: 'account-hash-a30a7d66c2ff5b5bfcb05a76913089df058aa947732870ae37725c21b5539414',
      weight: 1
    }
  ],
  actionThresholds: { deployment: 2, keyManagement: 3 }
}

7. Remove the first account

Signed by: account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8
Deploy hash: 4681eb165b21d1a640ed2124567b5d05b084f688683c020dcd904e70ed2bcb44
Deploy result:
{
  deploy: {
    hash: '4681eb165b21d1a640ed2124567b5d05b084f688683c020dcd904e70ed2bcb44',
    header: {
      account: '0202565899bab8f73265f51af616720988c2d677a0711dd70978754bd26b3b540f09',
      timestamp: '2021-09-25T19:26:39.320Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: 'aea7e47b87e69eda086f356f3701a11714a6c5b1d2a37ece49a91427a8141bcd',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { StoredContractByName: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-00c9336cc065e77df76827cb56cd59cd10ab723020b85ad893133397df6e655f'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-2cc3780a21e634a3567f6c25668c27eb1b486b08b4bd9188b3e9d9cf0d88799b-007'
    }
  ],
  mainPurse: 'uref-c2d7a501978e85ee3f681988698813b6ad36032a62457abde0e3c0ad866d236b-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
      weight: 3
    },
    {
      accountHash: 'account-hash-a30a7d66c2ff5b5bfcb05a76913089df058aa947732870ae37725c21b5539414',
      weight: 1
    }
  ],
  actionThresholds: { deployment: 2, keyManagement: 3 }
}

8. Remove the second account

Signed by: account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8
Deploy hash: e8c7f4e0d6a3f32b6fb4b3920d84af2927e434e2b89b98f2c3c37e848b0ffe57
Deploy result:
{
  deploy: {
    hash: 'e8c7f4e0d6a3f32b6fb4b3920d84af2927e434e2b89b98f2c3c37e848b0ffe57',
    header: {
      account: '0202565899bab8f73265f51af616720988c2d677a0711dd70978754bd26b3b540f09',
      timestamp: '2021-09-25T19:27:44.184Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: 'c43ee73fef3514e9502fc826799177e58d7833be89f36841f50e6c65f7692ee8',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { StoredContractByName: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-00c9336cc065e77df76827cb56cd59cd10ab723020b85ad893133397df6e655f'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-2cc3780a21e634a3567f6c25668c27eb1b486b08b4bd9188b3e9d9cf0d88799b-007'
    }
  ],
  mainPurse: 'uref-c2d7a501978e85ee3f681988698813b6ad36032a62457abde0e3c0ad866d236b-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-3694cd32b927993f8f1d800fb63a146f9d5dd0a9003c467d200058fe088b73d8',
      weight: 3
    }
  ],
  actionThresholds: { deployment: 2, keyManagement: 3 }
}
```



# Task 3: Demonstrate key management concepts by modifying the client in the Multi-Sig tutorial

> **Scenario 5: managing accounts with multiple keys**

***scenario5.js is below:***

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

(async function () {
    
    // Scenario #5 Description:
    // This example builds upon the Scenario #4 example, where you can set up multiple safe keys for account management.
    // In this scenario, the safe keys have the weight required to manage your keys and account.

    // So we will need 5 keys.
    // It would be 'safeAccount','safeAccount1','safeAccount2','browserAccount' and 'mobileAccount'.
    // To deploy updates to the Account we will use 'setAll' function of the keyManager.
    
    // To achieve the task, we will:
    // 1. Set weight of all safe accounts to 3.
    // 2. Set weight of browserAccount and mobileAccount to 1.
    // 3. Set Keys Management Threshold to 3.
    // 4. Set Deploy Threshold to 2.
    // 5. Deploy account changes using 'setAll' function.
    
    const masterKey = keyManager.randomMasterKey();
    const safeAccount = masterKey.deriveIndex(1);
    const safeAccount1 = masterKey.deriveIndex(2);
    const safeAccount2 = masterKey.deriveIndex(2);
    const browserAccount = masterKey.deriveIndex(3);
    const mobileAccount = masterKey.deriveIndex(4);
    
    console.log("Main account: " + safeAccount.publicKey.toHex());
    console.log("Safe account #1: " + safeAccount1.publicKey.toHex());
    console.log("Safe account #2: " + safeAccount2.publicKey.toHex());
    console.log("Browser account: " + browserAccount.publicKey.toHex());
    console.log("Mobile account: " + mobileAccount.publicKey.toHex());
    
    let deploy;

    console.log("\n0.1 Funding safe account.");
    await keyManager.fundAccount(safeAccount);
    await keyManager.printAccount(safeAccount);

    console.log("\n0.2 Install Keys Manager contract");
    deploy = keyManager.keys.buildContractInstallDeploy(safeAccount);
    await keyManager.sendDeploy(deploy, [safeAccount]);
    await keyManager.printAccount(safeAccount);
    
    // 1. Set weight of all safe accounts to 3.
    const safeAccountWeight = 3;
    // 2. Set weight of browserAccount and mobileAccount to 1.
    const keyAccountWeight = 1;
    const accounts = [
        { publicKey: safeAccount.publicKey, weight: safeAccountWeight },
        { publicKey: safeAccount1.publicKey, weight: safeAccountWeight },
        { publicKey: safeAccount2.publicKey, weight: safeAccountWeight },
        { publicKey: browserAccount.publicKey, weight: keyAccountWeight }, 
        { publicKey: mobileAccount.publicKey, weight: keyAccountWeight }, 
    ];
    
    // 3. Set Keys Management Threshold to 3.
    const keyManagementThreshold = 3;
    // 4. Set Deploy Threshold to 2.
    const deployThreshold = 2;
    
    // 5. Deploy account changes using 'setAll' function.
    console.log("\n 1. Set weight of both safe accounts to 3.");
    console.log("\n 2. Set weight of browserAccount and mobileAccount to 1.");
    console.log("\n 3. Set Keys Management Threshold to 3.");
    console.log("\n 4. Set Deploy Threshold to 2.");
    console.log("\n Update keys deploy.");
    
    deploy = keyManager.keys.setAll(safeAccount, deployThreshold, keyManagementThreshold, accounts);
    await keyManager.sendDeploy(deploy, [safeAccount]);
    await keyManager.printAccount(safeAccount);

})();
```

Run command to start the scenario 5:

`(env) root@ubuntu-vm:~/keys-manager/client# npm run start:scenario_5`

Full result is below:

```
(env) root@ubuntu-vm:~/keys-manager/client# npm run start:scenario_5

> keys-manager@1.0.0 start:scenario_5
> node -r dotenv/config ./src/scenario_5.js

Main account: 020282a8ad2deaee7240dfccd3e5f7947bc64b46dd512a80eb4208f1142f506351e1
Safe account #1: 0203d7c5b580f3d5ab22ca05f04604537ff034a210d1905a846550798ba1309ae522
Safe account #2: 0203d7c5b580f3d5ab22ca05f04604537ff034a210d1905a846550798ba1309ae522
Browser account: 0202b89ea0d040c2b0333164f6afccec4cdcb1d073576aa46fbe5076a92211bd1c0d
Mobile account: 020225735c96b587aa66e115c8315a407c8d629390c53afe43ba6a3c650a00ae16d8

0.1 Funding safe account.
Signed by: account-hash-253c76033edf1b813ab088e6fa5c3e95c71bef8299e38e3187b873b7837075e0
Deploy hash: 5d12f33ec712bc5de5666dd6514484254973a84a51b2ea9a037e64fdc2bf15af
Deploy result:
{
  deploy: {
    hash: '5d12f33ec712bc5de5666dd6514484254973a84a51b2ea9a037e64fdc2bf15af',
    header: {
      account: '01d70ad373c868b039da5fbec03d4ec6f8f961d96fb27d90360d109eae80eef26d',
      timestamp: '2021-09-25T19:23:14.444Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: 'f1742cfcfb70354c4bb16e386e7c4ca8dfdd0235d17382aa545548c589b52367',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { Transfer: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-ca46ce30a6e63509533c5f39cd99e85c59098eaae4fa1e4d670bc05872595e54',
  namedKeys: [],
  mainPurse: 'uref-1b297d1685d684ce9db7ef26136cb0f5c24af11e9070d221b7f140979c035a55-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-ca46ce30a6e63509533c5f39cd99e85c59098eaae4fa1e4d670bc05872595e54',
      weight: 1
    }
  ],
  actionThresholds: { deployment: 1, keyManagement: 1 }
}

0.2 Install Keys Manager contract
Signed by: account-hash-ca46ce30a6e63509533c5f39cd99e85c59098eaae4fa1e4d670bc05872595e54
Deploy hash: 163d3f21bdb4022ba2786ad6a9c456944b96d60f6045d047733966dc29e00bb3
Deploy result:
{
  deploy: {
    hash: '163d3f21bdb4022ba2786ad6a9c456944b96d60f6045d047733966dc29e00bb3',
    header: {
      account: '020282a8ad2deaee7240dfccd3e5f7947bc64b46dd512a80eb4208f1142f506351e1',
      timestamp: '2021-09-25T19:24:19.666Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: '8b75c87f0c5c33503df86050553e6a490fdee8d5154d9eececdc7c22618217c8',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { ModuleBytes: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-ca46ce30a6e63509533c5f39cd99e85c59098eaae4fa1e4d670bc05872595e54',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-f8848f2f4f2ab615e20c4268ea9ad99007a6ea1b048a03e9b2f359cde5998ac6'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-364f447ab7e381eee80e979639ac1ea112745d61958338a028e0f758d8e61f2a-007'
    }
  ],
  mainPurse: 'uref-1b297d1685d684ce9db7ef26136cb0f5c24af11e9070d221b7f140979c035a55-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-ca46ce30a6e63509533c5f39cd99e85c59098eaae4fa1e4d670bc05872595e54',
      weight: 1
    }
  ],
  actionThresholds: { deployment: 1, keyManagement: 1 }
}

 1. Set weight of both safe accounts to 3.

 2. Set weight of browserAccount and mobileAccount to 1.

 3. Set Keys Management Threshold to 3.

 4. Set Deploy Threshold to 2.

 Update keys deploy.
Signed by: account-hash-ca46ce30a6e63509533c5f39cd99e85c59098eaae4fa1e4d670bc05872595e54
Deploy hash: d49544a8560bd40733bd45177fb5195c820d8dafa4059c7ad9a0e94897f9b1cb
Deploy result:
{
  deploy: {
    hash: 'd49544a8560bd40733bd45177fb5195c820d8dafa4059c7ad9a0e94897f9b1cb',
    header: {
      account: '020282a8ad2deaee7240dfccd3e5f7947bc64b46dd512a80eb4208f1142f506351e1',
      timestamp: '2021-09-25T19:25:25.026Z',
      ttl: '30m',
      gas_price: 1,
      body_hash: 'af9ce0bf36a35c58d82a04a3172f66d5d9fab8081e50b4ba826e837d7c55a9b1',
      dependencies: [],
      chain_name: 'casper-net-1'
    },
    payment: { ModuleBytes: [Object] },
    session: { StoredContractByName: [Object] },
    approvals: [ [Object] ]
  }
}

[x] Current state of the account:
{
  _accountHash: 'account-hash-ca46ce30a6e63509533c5f39cd99e85c59098eaae4fa1e4d670bc05872595e54',
  namedKeys: [
    {
      name: 'keys_manager',
      key: 'hash-f8848f2f4f2ab615e20c4268ea9ad99007a6ea1b048a03e9b2f359cde5998ac6'
    },
    {
      name: 'keys_manager_hash',
      key: 'uref-364f447ab7e381eee80e979639ac1ea112745d61958338a028e0f758d8e61f2a-007'
    }
  ],
  mainPurse: 'uref-1b297d1685d684ce9db7ef26136cb0f5c24af11e9070d221b7f140979c035a55-007',
  associatedKeys: [
    {
      accountHash: 'account-hash-61ece15a621e97126c06b9b86cb3f649c64108986255bf4a8f3ac93456c56919',
      weight: 1
    },
    {
      accountHash: 'account-hash-89b24420aaeaa466c750cb5dc8c91b4ea1472475d243ea366c0058877273c6b6',
      weight: 3
    },
    {
      accountHash: 'account-hash-c0fa8a2beb82428f201a8a65d4e543b4d21842aa44c8a8f4d149a66eec44f9c5',
      weight: 1
    },
    {
      accountHash: 'account-hash-ca46ce30a6e63509533c5f39cd99e85c59098eaae4fa1e4d670bc05872595e54',
      weight: 3
    }
  ],
  actionThresholds: { deployment: 2, keyManagement: 3 }
}
```


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

Transfer command:

`(env) root@ubuntu-vm:~# casper-client transfer --transfer-id 555 --node-address http://135.181.214.240:7777 --amount 250000000000 --secret-key /root/key/secret_key.pem --chain-name casper-test --target-account 0203b53209c207651123979813dea3390c76cedf87286a77a5a9347794eeb9329c82 --payment-amount 500000000`

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

Check transfer:

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


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

## Delegate

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

## Undelegate

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