Skip to content
Branch: master
Find file History
This branch is 1 commit ahead, 2 commits behind dev.

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

cargo casperlabs


Build Status Documentation License

A command line tool for creating a Wasm smart contract and tests for use on the CasperLabs network.


cargo casperlabs is a Cargo subcommand which can be installed via cargo install:

cargo install cargo-casperlabs

To install from the latest dev branch:

git clone
cd CasperLabs/execution-engine/cargo-casperlabs
cargo install cargo-casperlabs --path=.


To create a folder "my_project" containing an example contract and a separate test crate for the contract:

cargo casperlabs my_project

This creates the following files:

├── contract
│   ├── .cargo
│   │   └── config
│   ├── Cargo.toml
│   ├── rust-toolchain
│   └── src
│       └──
└── tests
    ├── Cargo.toml
    ├── rust-toolchain
    ├── src
    │   └──
    └── wasm
        ├── mint_install.wasm
        ├── pos_install.wasm
        └── standard_payment.wasm

Building the contract

To build the contract, the correct version of Rust must be installed along with the Wasm target:

cd my_project/contract
rustup install $(cat rust-toolchain)
rustup target add --toolchain=$(cat rust-toolchain) wasm32-unknown-unknown

The contract can now be built using:

cargo build --release

and will be built to my_project/contract/target/wasm32-unknown-unknown/release/contract.wasm.

Testing the contract

Running the test will automatically build the contract in release mode, copy it to the "tests/wasm" folder, then build and run the test:

cd my_project/tests
cargo test


Licensed under the CasperLabs Open Source License (COSL).

You can’t perform that action at this time.