Crates.io | cargo-casperlabs |
lib.rs | cargo-casperlabs |
version | 0.9.1 |
source | src |
created_at | 2020-02-13 21:17:53.090559 |
updated_at | 2020-07-31 04:02:19.152758 |
description | Command line tool for creating a Wasm smart contract and tests for use on the CasperLabs network. |
homepage | https://casperlabs.io |
repository | https://github.com/CasperLabs/CasperLabs/tree/master/execution-engine/cargo-casperlabs |
max_upload_size | |
id | 208121 |
size | 1,134,063 |
cargo casperlabs
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 https://github.com/CasperLabs/CasperLabs
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:
my_project/
├── contract
│ ├── .cargo
│ │ └── config
│ ├── Cargo.toml
│ ├── rust-toolchain
│ └── src
│ └── main.rs
├── tests
│ ├── build.rs
│ ├── Cargo.toml
│ ├── rust-toolchain
│ ├── src
│ │ └── integration_tests.rs
│ └── wasm
│ ├── mint_install.wasm
│ ├── pos_install.wasm
│ ├── standard_payment_install.wasm
│ └── standard_payment.wasm
└── .travis.yml
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
.
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).