RegisterContractCode, then deploy as many instances as you like via DeployContract.
When to use this
- Custom logic that the native primitives don’t cover.
- An on-chain price oracle, escrow with bespoke conditions, or governance contract.
- Migrating EVM-style logic to Sigil’s WASI runtime.
Prerequisites
- Rust toolchain with the
wasm32-wasip2target installed. - A funded controller DID for the contract.
Recipe
Write a minimal contract
Contracts target the Sigil contract ABI exposed by Build it:
sigil-wasm. The simplest contract has an execute entry point.hello_contract.rs
Register the code
RegisterContractCode publishes the bytes on-chain and records the BLAKE3 hash, license, and source pointers.The Rust SDK has a typed builder for this:code_hash from the receipt — you’ll reference it in the next step.Deploy a contract instance
DeployContract instantiates a contract bound to a specific DID, controller, and zone.ControlPolicy for upgrades and invocations.Inspecting a deployment
code_hash, controller, upgrade policy, call policy, allowed host functions, and the contract’s current storage root.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
code_hash not registered | DeployContract before RegisterContractCode confirmed | Wait for the registration receipt to finalise |
wasm validation failed | Module uses unsupported imports | Build with the canonical sigil-contract template; remove non-WASI imports |
host function not allowed | Contract calls an import outside allowed_host_functions | Add it to the deploy policy or remove the call |
gas limit exceeded | Execution took more gas than gas_limit | Raise gas_limit or optimise the contract |
See also
- Primitive: smart contracts — runtime model and host ABI.
- Primitive: organisation zones — isolating contracts per org.
- Transaction reference: RegisterContractCode