# 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

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

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

### 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

Set up Local Network and view the Network State

Setting up the client

Testing the client

Final State

### 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);
})();
```

npm run start:two

Secondary key can only perform deployment but not key management.
6. Make a transfer from faucet using the secondary account. (Successful)

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

### 4. Learn to transfer tokens to an account on the Casper Testnet.
A Transfer of 3 CSPR from one account to another.

Check Deployment Status using deploy_hash

Get State Root Hash using block_hash

Query the Source Account using state root hash

Query the Target Account using state root hash

Query the source and target account balances one by one

Query full transfer details

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

100 CSPR staked

Staking Rewards after 4+ hours of staking

Undelegate 100 CSPR + rewards

Undelegated 100.08 CSPR

Account Status 24 hours after undelegating
