For the complete documentation index, see llms.txt. This page is also available as Markdown.

Optimization

Before progressing, ensure you've completed the first steps. It's important to have either the Node.js REPL or the wasmd Go CLI pre-configured.

Step 1: Obtaining and Compiling the Contract Code

Get the cw-contracts repository first. Then:

git clone https://github.com/InterWasm/cw-contracts
cd cw-contracts
git checkout main
cd contracts/nameservice
rustup default stable
cargo wasm

To trim it down, you can run:

RUSTFLAGS='-C link-arg=-s' cargo wasm

This command yields a much compact version, roughly 165kB in size. This file or another optimized version will eventually get uploaded to the blockchain.

Step 2: Running Unit Tests

Unit tests ensure the contract operates as expected:

RUST_BACKTRACE=1 cargo unit-test

Step 3: Optimizing for Deployment

The rust-optimizer is the tool for this task and it allows third parties to validate the legitimacy of the contract.

The rust-optimizer requires Docker.

On Linux and Mac, execute:

For Windows:

After optimization, the resultant binary is located under the artifacts directory and will be approximately 138 kB in size.

Last updated