cargo-casperlabs

Crates.iocargo-casperlabs
lib.rscargo-casperlabs
version0.9.1
sourcesrc
created_at2020-02-13 21:17:53.090559
updated_at2020-07-31 04:02:19.152758
descriptionCommand line tool for creating a Wasm smart contract and tests for use on the CasperLabs network.
homepagehttps://casperlabs.io
repositoryhttps://github.com/CasperLabs/CasperLabs/tree/master/execution-engine/cargo-casperlabs
max_upload_size
id208121
size1,134,063
crate-owners (github:casperlabs:crate-owners)

documentation

https://docs.rs/cargo-casperlabs

README

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
│       └── 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

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).

Commit count: 0

cargo fmt