Guest exports
Functions the contract exports for the VM to invoke. (Functions the contract imports from the host are in the other pages of this section.)
Every contract must also export its linear memory.
call live
call(input_ptr: i32, input_len: i32)The entry point for every contract call, read or write.
- The VM writes the call data (the JSON payload, see ABI & call data) into the contract's memory at offset 64, then calls
call(64, len). - A contract without parameters,
call(), is also accepted; it then cannot read the input. - The result is whatever the contract last passed to
set_return. - The whole call tree commits only if nothing traps.
Keep offset 64 free
Because the input is copied to memory[64 .. 64 + len], a contract must not keep data it needs there. With the Rust toolchain's default layout (stack first, growing down from the top of the first megabyte) this holds for inputs of normal size.
Analogs: CosmWasm execute and query, NEAR @call / @view.
init live
init()Constructor, run once when the contract is deployed — if the module exports it; a missing init is not an error. It may write storage and emit events.
init receives no input, and get_caller() returns nothing inside it. To record an owner or take parameters, handle an initialize function in call instead: the deploy transaction calls it with the deployer as caller when init_args are given (see Deploy). Guard it so it runs only once.
Analogs: CosmWasm instantiate, NEAR #[init].
query planned
A read-only entry point the runtime would forbid from writing. Until then, read through call with dry_run: true (POST /api/v1/contracts/:address/call).
migrate planned
Runs after replacing the bytecode at the same .app address, gated by the owner or governance.
sudo planned
Protocol and governance actions only (pause, parameter injection) — never reachable from a user transaction.
reply planned
Receives the result (id, result) of an asynchronous sub-message. Needs asynchronous cross-contract calls, which are not implemented yet.
Analogs: CosmWasm reply, NEAR promise callbacks.