Overview
Thecowboy_sdk is a Python library that provides the canonical developer experience for writing Cowboy actors. It ships with the PVM and lives at node/pvm/Lib/cowboy_sdk/ in the monorepo. On deployed actors, sys.path already includes it — you can import cowboy_sdk directly.
The SDK is specified by CIP-6. APIs may still evolve; see the CIP for the authoritative surface.
What the SDK Gives You
| Feature | Module | Purpose |
|---|---|---|
@actor decorator | cowboy_sdk.actor | Injects self.storage, self.address, and wires CBOR auto-serialization |
runner.continuation FSM | cowboy_sdk.runner | Pause an actor mid-handler while a runner job is in flight; resume on callback |
CowboyModel | cowboy_sdk.models | Typed, CBOR-serializable structured data |
capture() | cowboy_sdk.continuation | Explicitly declare variables preserved across await |
codec | cowboy_sdk.codec | CBOR encode/decode with deterministic ordering |
runtime | cowboy_sdk.runtime | Access to block context, gas, events, logging |
SoftFloat | cowboy_sdk.types | Deterministic floating-point type |
mock_host | cowboy_sdk.mock_host | Stub the PVM host for unit tests off-chain |
Two Ways to Write an Actor
Low-level (host API): importpvm_host and manage bytes serialization yourself. Used by actors/feed-subscriber/main.py.
@actor decorator auto-CBOR-encodes values written to self.storage, injects self.address, and registers handlers with the PVM. CowboyModel fields are schema-checked and serialize deterministically.
Continuation FSM for Off-Chain Jobs
Calling a runner (LLM/HTTP/MCP) is asynchronous — the result arrives in a later block as a callback transaction. The SDK compiles@runner.continuation methods into a synchronous state machine under the hood so you can write code that looks sequential:
await, persists captured variables, and resumes on the callback. See CIP-6 Appendix A for the full rule set (await point limits, non-reversible send, etc.).
Unit Testing
Usecowboy_sdk.mock_host to run actors under pytest without a live chain:
Where to Find More
- Source:
node/pvm/Lib/cowboy_sdk/— read the code directly - Spec: CIP-6 — normative API
- Examples:
node/examples/llm_chat/,node/examples/ring-demo/,node/examples/token/— end-to-end actors - Actor anatomy: Minimal Actor
- Transaction format: tx-format
- Best practices: best-practices

