Compile a Rust smart contract module#
This guide will show you how to compile smart contract module written in Rust to a Wasm module.
Preparation#
Make sure to have Rust and Cargo installed and the wasm32-unknown-unknown
target, together with cargo-concordium
and the Rust source code for a smart
contract module, you wish to compile.
See also
For instructions on how to install the developer tools see Install tools for development.
Compiling to Wasm#
To help building smart contract modules and to take advantage of features
such as contract schemas, we recommend using the
cargo-concordium
tool for building Rust smart contracts.
In order to build a smart contract, run:
$cargo concordium build
This uses Cargo for building, but runs further optimizations on the result.
See also
For building the schema for a smart contract module, some further preparation is required.
Note
It is also possible to compile using Cargo directly by running:
$cargo build --target=wasm32-unknown-unknown [--release]
Note that even with --release
set, the produced Wasm module includes
debug information.