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.

Files

Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
tests
.gitignore
Cargo.toml
README.md
build.rs

README.md

cargo casperlabs

LOGO

Build Status Crates.io Documentation License

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

Installation

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 https://github.com/CasperLabs/CasperLabs
cd CasperLabs/execution-engine/cargo-casperlabs
cargo install cargo-casperlabs --path=.

Usage

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:

my_project/
├── contract
│   ├── .cargo
│   │   └── config
│   ├── Cargo.toml
│   ├── rust-toolchain
│   └── src
│       └── lib.rs
└── tests
    ├── build.rs
    ├── Cargo.toml
    ├── rust-toolchain
    ├── src
    │   └── integration_tests.rs
    └── 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

License

Licensed under the CasperLabs Open Source License (COSL).

You can’t perform that action at this time.