An Introduction to Casper Network and How to Set Up its Environment

Posted By : Vishal

Mar 26, 2021

Casper Network is a Proof of stake blockchain built over CBC Casper specification. Using a proof of stake architecture enables sharding a database scaling method. Businesses can use Casper for creating permissioned or private applications. The key feature that Casper provides is predictable gas fees, Upgradeable contracts, and WebAssembly. 

 

The native coin of the Casper Network is CSPR. As PoS blockchain uses the validators to participate in consensus mechanisms for making it secure and uphold the network. So this CSPR coin is used to pay the validators as a reward, also users have to pay gas fees in CSPR for on-chain actions.

 

Currently, Casper Network is not live yet and their coin is available on the coin list for the initial sale.

 

In this blog, we are going to show to set up the environment for the Casper Network contract development. Currently, Casper uses Rust to write smart contracts like we use solidity with Ethereum/Binance.

 

Prerequisites:- 

 

  1. Rust
  2. Cmake
  3. Google Protobuf Compiler

 

Step 1: Install dependencies 

 

cargo install cargo-casper

 

Step 2: Setup your Project. By using this command it will create a new project and its structure with a sample contract and its corresponding test cases.

 

cargo casper my-project


Step 3: Now you have the project set up at your end. You need to compile the contract and run the corresponding in order to test all things are working fine.

 

// Install required tools
cd contract
rustup install $(cat rust-toolchain)
rustup target add --toolchain $(cat rust-toolchain) wasm32-unknown-unknown

// Compile and create a build
cargo build --release

// Run test cases

cd ../tests
cargo test


Step 4: Once this sample code is working. You can use the code of this repository for standard ERC20 over Casper Network. Simply replace the main.rs and test folder from Repository.

Link: https://github.com/casper-ecosystem/erc20

 

Step 5: Install the Casper Client. This is a CLI tool that can be used to interact with blockchain and contracts.

 

curl -JLO https://bintray.com/casperlabs/debian/download_file?file_path=casper-client_0.9.3-0_amd64.deb
sudo apt install -y ./casper-client_0.9.3-0_amd64.deb

// For interacting with contracts
casper-client put-deploy  --session-hash <HEX STRING> --session-entry-point <FUNCTION_NAME>

 

Conclusion: By following this blog you will get an idea about Casper and how we can create your contract over the network.

Leave a

Comment

Name is required

Invalid Name

Comment is required

Recaptcha is required.

blog-detail

November 21, 2024 at 12:00 pm

Your comment is awaiting moderation.

By using this site, you allow our use of cookies. For more information on the cookies we use and how to delete or block them, please read our cookie notice.

Chat with Us
Telegram Button
Youtube Button

Contact Us

Oodles | Blockchain Development Company

Name is required

Please enter a valid Name

Please enter a valid Phone Number

Please remove URL from text