Contracts
Test before compiling
Section titled “Test before compiling”labcoat testlabcoat test my-tokenNative Rust integration tests run contracts through labcoat-test, keeping the
fast feedback loop outside the chain. Each ContractHarness has isolated
in-memory storage that persists across calls on that harness. Use
storage_value to inspect raw state or set_storage to seed a test fixture.
Generated projects obtain the harness from this repository’s matching
cli-vX.Y.Z Git tag, so the CLI and test API advance as one release.
labcoat build my-tokenCompilation writes:
build/my-token.wasm: raw deployable module.build/my-token.wasm.gz: compressed distribution artifact.build/my-token.abi.json: opcode, input, and output metadata.
Deploy
Section titled “Deploy”labcoat deploy my-token --dry-runlabcoat deploy my-token
# Advanced: deploy an external raw artifact without compiling a packagelabcoat deploy --wasm /path/to/my-token.wasm --name my-tokenPackage deployment always recompiles the selected contract, uses a Bitcoin
commit/reveal envelope, waits for the create trace, and records the resulting
block:tx ID in labcoat.lock.
Simulate and call
Section titled “Simulate and call”labcoat simulate counter get_countlabcoat call counter incrementlabcoat call my-token mint 500labcoat call registry set_name "Alice Smith"labcoat call registry set_owner 2:3Named selectors are resolved for the deployed contract. When the generated
local ABI belongs to the exact Wasm recorded in labcoat.lock, Labcoat uses it
without an indexer metadata request. If the local build differs, Labcoat warns
and transparently uses deployed metadata. Pass one shell argument per ABI
parameter: decimal or 0x hexadecimal for u128, one UTF-8 argument for
String, and decimal block:tx for AlkaneId. Strings are encoded across as
many little-endian cells as needed. Use a numeric opcode to pass raw cellpack
arguments for Vec<T>, custom types, or other advanced calls.
Simulation never broadcasts, but it always executes the deployed contract
against live indexed chain state. Use labcoat test <package> to execute an
undeployed local build in the isolated host test runtime. Calls create a
transaction and wait for indexing and decoded execution status.
Use ordinary shell scripts to compose multiple commands. Labcoat does not currently include a contract script runner.
labcoat trace <txid> --waitTrace output includes decoded create, invoke, return, and revert events across every protostone in the transaction.