cargo-contractis a CLI tool which helps you develop smart contracts in Parity's ink!.
ink! is a Rust eDSL which allows you to write smart contracts for blockchains built on the Substrate framework.
Guided Tutorial for Beginners • ink! Documentation Portal
More relevant links:
- Talk to us on Element or Discord
ink!‒ The main ink! repository with smart contract examples- Canvas UI ‒ Frontend for contract deployment and interaction
- Canvas Node ‒ Simple Substrate blockchain which includes smart contract functionality
This is a forked version to provide debug feature in Patract's toolchain.
-
Step 1:
rustup component add rust-src. -
Step 2: Install
binaryenin a version >= 99:- Debian/Ubuntu:
apt-get install binaryen - Homebrew:
brew install binaryen - Arch Linux:
pacman -S binaryen - Windows: binary releases are available
There's only an old version in your distributions package manager? Just use a binary release.
- Debian/Ubuntu:
-
Step 3:
cargo install --git https://github.com/patractlabs/cargo-contract.git --branch tag-v0.12.1 --force
You can always use cargo contract help to print information on available
commands and their usage.
For each command there is also a --help flag with info on additional parameters,
e.g. cargo contract new --help.
Creates an initial smart contract with some scaffolding code into a new
folder my_contract .
The contract contains the source code for the Flipper
contract, which is about the simplest "smart" contract you can build ‒ a bool which gets flipped
from true to false through the flip() function.
Compiles the contract into optimized WebAssembly bytecode, generates metadata for it,
and bundles both together in a <name>.contract file, which you can use for
deploying the contract on-chain.
cargo contract build must be run using the nightly toolchain. If you have
rustup installed, the simplest way to
do so is cargo +nightly contract build.
To avoid having to always add +nightly you can also set nightly as the default
toolchain of a directory by executing rustup override set nightly in it.
The different of the forked from the official branch is that we have debug flag in command build.
This is used for wasm backtrace, for adding --debug will retain the Custom/Name section part in wasm. And in debug mode,
the default optimization for wasm-opt is 0, and without debug, the default optimization is 3 in original version.
You can also set the optimization level by --optimization-passes in debug mode.
...
USAGE:
cargo contract build [FLAGS] [OPTIONS]
FLAGS:
-d, --debug Enable debug info in the wasm bundle
...
Checks that the code builds as WebAssembly. This command does not output any <name>.contract
artifact to the target/ directory.
The entire code within this repository is licensed under the GPLv3.
Please contact us if you have questions about the licensing of our products.

