Skip to main content

Overview

This page lists the example actors that ship with the Cowboy monorepo. They cover everything from “hello world” to full LLM chat with runner callbacks.
APIs shown here follow CIP-6. Check the CIP for authoritative semantics.

Starter Actors

Two tiny reference actors live at the repo root under actors/ and are scaffolded into every project by cowboy init.

actors/hello/main.py — Minimal Counter

A class-based actor using the low-level PVM host API:
class Actor:
    """A Cowboy actor deployed on-chain."""

    def __init__(self):
        self.counter = 0

    def increment(self):
        self.counter += 1
        return self.counter

    def get_count(self):
        return self.counter
Deploy and call:
cowboy actor deploy --code actors/hello/main.py --salt hello
cowboy actor execute --actor <ADDR> --handler increment --payload 0x
cowboy actor execute --actor <ADDR> --handler get_count --payload 0x

actors/feed-subscriber/main.py — Watchtower Feed Consumer

A function-based actor that subscribes to a Watchtower stream (CIP-7) and stores incoming messages. Demonstrates:
  • Explicit pvm_host.get_state / set_state with manual bytes serialization
  • handle_message — the handler invoked by the chain when stream data arrives
  • Bounded storage (MAX_STORED_MESSAGES = 100)
Use this as a template when you want to consume on-chain data feeds.

Worked End-to-End Examples

Longer, self-contained demos live under node/examples/.

node/examples/llm_chat/ — LLM Chat with Runner Callback

End-to-end actor using the CIP-6 SDK:
  • @actor decorator injects self.storage
  • @runner.continuation splits the chat method into a suspend/resume FSM
  • Submits an LLM job to a runner and resumes in a later block when the result arrives
  • Uses CowboyModel (ChatEntry) for typed, CBOR-serialized records
  • Includes a browser frontend under frontend/ and a deploy.sh script
This is the best reference for production-shaped actors.

node/examples/ring-demo/ — Multi-Actor Topology

Demonstrates inter-actor messaging by wiring actors into a ring and passing a token around. Useful for understanding:
  • Asynchronous message ordering
  • Cross-actor send + callback patterns
  • Deploying multiple actors in one script (deploy_ring.sh)

node/examples/token/ — CIP-20 Fungible Token

A minimal CIP-20 fungible token implementation — transfer, mint, burn, approve. Shows how to work with the token registry crate from Python.

Other Examples

PathTopic
node/examples/multi_call/Chained actor calls within a single transaction
node/examples/restart_test/Checkpoint/resume across process restarts
node/examples/proof/Generating and verifying state proofs
node/examples/indexer_test/Indexer integration testing
node/examples/poison_tx_test/Malformed transaction handling

See Also