Overview
cowboy_sdk.runtime is the supported, developer-facing wrapper over the low-level pvm_host bindings. Actors should call runtime.* (and the higher-level self.storage, call(), send() helpers) rather than pvm_host directly. All listed signatures are from the shipping SDK.
Execution context
Mode helpers:
mode() returns "fsm" (production), "checkpoint" (debug-only), or "local"; is_production() / is_development() / is_checkpoint_mode() are the boolean forms; require_fsm() raises unless running in FSM mode.
State
Preferself.storage[...] (the @actor proxy, with automatic CBOR encoding). The raw layer underneath:
Events and gas
Gas is metered for you. The runtime and host account for the Cycles a handler consumes and the Cells its data occupies, and enforce both budgets; actor code does not participate in that accounting. Write handlers as if gas accounting does not exist, and use
estimate_gas against a node when you need real cost figures.
Ownership and lifecycle
Messaging and jobs
Timers (CIP-5)
Event subscriptions (CIP-29)
Randomness and crypto
Code upgrade
Tokens (CIP-20)
The token surface (token_create, token_balance_of, token_total_supply, token_transfer, token_approve, token_allowance, token_transfer_from, token_mint, token_burn) is covered with examples in the CIP-20 spec; amounts are int base units (u128), addresses 20 bytes, token_id 32 bytes.
Behavior under the mock host
Unit tests run againstcowboy_sdk.mock_host (usually via cowboy_sdk.testing.SimulatedChain). Context, state, ownership, timers, subscriptions, and call_actor (with set_call_handler) all work in-memory. emit_event works under SimulatedChain (which captures events for chain.events()) but not under the bare mock host; the mock implements no gas meter, so gas is not simulated in unit tests — use estimate_gas against a real node when you need cost figures. keccak256 falls back to SHA-256, and randomness and the token_* operations require a real chain.
Further reading
- CIP-6 §12 — Runtime Module — normative spec for the core of this surface (mode helpers, CIP-29 subscriptions, and some context getters are shipping-SDK additions beyond §12)
- SDK Overview — the high-level
@actor/ continuation / model layer - PVM Reference — validation rules and determinism guards

