Building Contracts
Thexyz program build command compiles your Rust contract to optimized WebAssembly (Wasm).
Usage
Cargo.toml is located).
Build Methods
Docker Build (Default)
Uses the official CosmWasm optimizer for reproducible builds:Output
Output
- Reproducible builds (same output every time)
- Optimized for size
- Production-ready
- Docker installed and running
Local Build
Uses your local Rust toolchain:Output
Output
- Faster iteration
- No Docker required
- Larger file size
- Not reproducible
- Rust with
wasm32-unknown-unknowntarget:
Options
Output Location
Docker Build
Local Build
Size Comparison
XYZ Chain has a maximum contract size of 800 KB. Both methods typically produce contracts well under this limit.
Build Process
Docker Build Flow
Local Build Flow
Development Workflow
Fast Iteration (Local)
For quick development cycles:Production (Docker)
For deployments:Troubleshooting
Docker not found
Docker not found
Install Docker from https://docker.com or use local build:
Cargo.toml not found
Cargo.toml not found
Run the command from your project root:
wasm32 target not installed
wasm32 target not installed
Install the Wasm target:
Build fails with errors
Build fails with errors
Check your Rust code compiles:Fix any errors before building for Wasm.
Contract too large
Contract too large
- Use Docker build (smaller output)
- Remove unused dependencies
- Optimize code for size