---
# System prepended metadata

title: Get Started With Casper (v1.3.2)

---

# Get Started With Casper (v1.3.2)
## Hackathon: The Friendly Hackathon: Start Building on Casper!
### Task 1: Create and deploy a simple, smart contract with cargo casper and cargo test
- In a new VM install Rust:
`# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
Customize it so it installs the nightly builds. 
Configure current shell running:
`# source $HOME/.cargo/env`
Check it works:
`# rustup --version`
`rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is  rustc 1.57.0-nightly (9bb77da74 2021-09-13)`
- Install cmake:
`# snap install cmake --classic`
`# cmake --version`
`cmake version 3.21.2`
`# apt install gcc`
- Install Casper crates:
`# cargo install cargo-casper --version 1.3.2`
- Create a new project
`# cd`
`# cargo casper casper-simple-contract`
`# cd casper-simple-contract`
- Compile
`# cd contract`
`# rustup install $(cat rust-toolchain)`
`# rustup target add --toolchain $(cat rust-toolchain) wasm32-unknown-unknown`
![](https://i.imgur.com/q85lPK0.png)
- Edit Cargo.toml and add `cargo-features = ["edition2021"]`to the top of the file. Then, build:
`# cargo build --release`
![](https://i.imgur.com/aLdxFE2.png)
As a result we get a `contract.wasm` file:
`# ls target/wasm32-unknown-unknown/release/`
![](https://i.imgur.com/IJjrHYN.png)


- Test the contract
`# cd ../tests`
`# cargo test`
![](https://i.imgur.com/B9uDPBO.png)


apt -y install libssl-dev
apt -y install libssl-dev

cd
git clone https://github.com/rust-lang/cargo
cd cargo
cargo build --release

### Task 2: Complete tutorial "A Counter Contract Tutorial"
- Install `casper-client`:
`# rustup toolchain install nightly-2021-06-17`
`# cargo +nightly-2021-06-17 install casper-client --locked`
`# cargo install casper-client --locked`


- View the network state
-- Show the faucet account
`# nctl-view-faucet-account`
![](https://i.imgur.com/l4fht2T.png)
-- Get the state-root-hash
`casper-client get-state-root-hash --node-address http://localhost:11101/`
![](https://i.imgur.com/Vs95Wna.png)
-- Get the network state
`casper-client query-state --node-address http://localhost:11101 --state-root-hash 63bc64d967aee7ef0c1285a1630bd51a2893932b017d43acbf0c7d383f50f84a --key account-hash-0607801997fa7806ed66aa9d860900eb44a3fca894780f1d552a560debf3e779`
![](https://i.imgur.com/Df8r6au.png)

- Download the contract
` git clone https://github.com/casper-ecosystem/counter`
- Build the contract
`# cd counter`
`# make prepare`
`# make test`
- Deploy the contract
`casper-client put-deploy --node-address http://localhost:11101 --chain-name casper-net-1 --secret-key /home/dhernando/nctl/casper-node/utils/nctl/assets/net-1/faucet/secret_key.pem --payment-amount 5000000000000 --session-path ./target/wasm32-unknown-unknown/release/counter-define.wasm`
![](https://i.imgur.com/zvi9RS1.png)
- Verify the deploy was successful
`casper-client get-deploy --node-address http://localhost:11101 f98095d093eba1e3dcf7f4a1663c5e77b5dbd620e5f6be1ab5aa97d364294910`
- Now get new state-root-hash
`casper-client get-state-root-hash --node-address http://localhost:11101`
![](https://i.imgur.com/q6sqCjJ.png)
- Get the updated newtork state
`casper-client query-state --node-address http://localhost:11101 --state-root-hash 63bc64d967aee7ef0c1285a1630bd51a2893932b017d43acbf0c7d383f50f84a --key account-hash-0607801997fa7806ed66aa9d860900eb44a3fca894780f1d552a560debf3e779`
- Retrieve the counter
`casper-client query-state --node-address http://localhost:11101 --state-root-hash 531a16e6e012c669e03ad18c7fa2a1207675fc3993ff2e508641b00d7313dc78 --key account-hash-0607801997fa7806ed66aa9d860900eb44a3fca894780f1d552a560debf3e779 -q "counter/count"`
![](https://i.imgur.com/2wmPhbC.png)
- Now increment the counter
`casper-client put-deploy --node-address http://localhost:11101 --chain-name casper-net-1 --secret-key /home/dhernando/nctl/casper-node/utils/nctl/assets/net-1/faucet/secret_key.pem --payment-amount 5000000000000 --session-name "counter" --session-entry-point "counter_inc"`
- And check the counter again with the new state-root-hash
`casper-client query-state --node-address http://localhost:11101 --state-root-hash fa8a6a9c2579fd88f20b8cc19b2752f48a2d40af5aff14b14cbf5918955da038 --key account-hash-0607801997fa7806ed66aa9d860900eb44a3fca894780f1d552a560debf3e779 -q "counter/count"`
![](https://i.imgur.com/KM0dAjJ.png)
- Increment the counter deploying the counter-call contract
`casper-client put-deploy --node-address http://localhost:11101 --chain-name casper-net-1 --secret-key /home/dhernando/nctl/casper-node/utils/nctl/assets/net-1/faucet/secret_key.pem --payment-amount 5000000000000 --session-path ./target/wasm32-unknown-unknown/release/counter-call.wasm`
- And check the counter again with the new state-root-hash
`casper-client query-state --node-address http://localhost:11101 --state-root-hash ab0e95f4dd0387b7fac82bf6fe5b7f019b29490bd6c16a4338a257e10b1cbc95 --key account-hash-0607801997fa7806ed66aa9d860900eb44a3fca894780f1d552a560debf3e779 -q "counter/count"`
![](https://i.imgur.com/aV8x4M9.png)
HOORAY!
### Task 3: Key management activity
- Download the key management contract and build it
`git clone https://github.com/casper-ecosystem/keys-manager`
`cd keys-manager`
`cd contract`
`cargo build --release`
- Set up the client
`cd ../client`
`touch .env`
`nano .env`
Edit like this:
```
BASE_KEY_PATH=/home/dhernando/nctl/casper-node/utils/nctl/assets/net-1/faucet/
NODE_URL=http://localhost:11101/rpc
```
And run:
`npm install`
- Test the client
`npm run start:atomic`
[Output here](https://hackmd.io/@K48d9TN9T2q7ERX4H27ysw/rkgHSmzmF)
- **Now, I'll adapt the client example to implement the scenario 3: signing transactions with multiple keys**
-- Create a new js file called `scenario-3.js` in the source folder. Add [this code](https://hackmd.io/@K48d9TN9T2q7ERX4H27ysw/ryWjoXfXY)
-- Modify the package.json to add a new script task and run it with `npm run start:scn3`
-- At step 2 the output shows that one single key can sign a transfer funds deploy action.
![](https://i.imgur.com/Jrv2bzY.png)
-- At step 3 a transfer funds action is shown with just one signer (approval).
![](https://i.imgur.com/hvUt82R.png)
-- At step 4 the output shows two keys are signing a key management task like adding a new key to the account.
![](https://i.imgur.com/XOgFYcf.png)
-- [Full output here](https://hackmd.io/@K48d9TN9T2q7ERX4H27ysw/ryWjoXfXY)
### Task 4: Learn to transfer tokens from one account to another
- Create an ccount
`cd myaccount`
`casper-client keygen .`
- Fund the account in CSPR.live
![](https://i.imgur.com/nz3te14.png)
- Create a target account
`Public key: 0111bc2070a9af0f26f94b8549bffa5643ead0bc68eba3b1833039cfa2a9a8205d`
- Get the IP address of a testnet peer
`164.90.198.193:35000`
- Transfer some motes
`casper-client transfer --id 1 --transfer-id 123456789012345 --node-address http://164.90.198.193:7777 --amount 15000000000 --secret-key /home/dhernando/casper/myaccount/secret_key.pem --chain-name casper-test --target-account 0111bc2070a9af0f26f94b8549bffa5643ead0bc68eba3b1833039cfa2a9a8205d --payment-amount 1000
`
![](https://i.imgur.com/Vt2H8y6.png)

### Task 5: Learn to delegate and undelegate on the testnet

- Delegate stake from 'myaccount' to a validator following the instructions.
![](https://i.imgur.com/J9DMxvD.png)
Delegated amount is shown in the account summary:
![](https://i.imgur.com/PNb8B9u.png)
- Now undelegate stake
![](https://i.imgur.com/yYgIsn5.png)



