Skip to main content

Synopsis

cowboy run is the inner loop: one local invocation of one handler, with no chain involved. The default output is the decoded return value, the decoded state writes, the off-chain calls, and the gas.

Behavior

  1. Resolve the payload: --payload as hex (0x optional) or @path for raw bytes; --payload-text as UTF-8 bytes; --payload-json as CBOR-encoded JSON. With none, the payload is empty (0x).
  2. Prepare the actor: compile the named target (or the project’s only actor), or the standalone file given by --code (- reads stdin). Off-chain calls are answered by the --stub* flags or by a local container when none is given.
  3. Run the handler through the cowboy-dev-runner simulator with the cycles limit and any --initial-state or --state file. With --state, a successful run saves the state it leaves back to that file.
  4. Print the decoded output, then State:, Off-chain calls:, Events:, Messages:, Timers:, and Deferred transactions: sections when non-empty, then Gas used: <n>.
  5. With --expect, compare the raw returned bytes: print Output matches --expect. or fail with does not match --expect.
  6. A handler that raises prints the exception type and message, the Actor line in the developer’s source when the build’s source map covers it, and the traceback; the process exits 1.
Under --json stdout carries one envelope with the simulator’s own fields (output, state, gas_used, events, messages, timers, deferred_transactions) plus decoded_output, decoded_state, offchain_calls, the error fields, actor_location, and the expected/matched pair when --expect was given. A reverted run still reports the state, events, and gas it produced.

The dev runner

The simulator is a separate cowboy-dev-runner binary. It is located by, in order: the COWBOY_DEV_RUNNER environment variable when set and non-empty; a cowboy-dev-runner file next to the cowboy executable; then cowboy-dev-runner on PATH. A world-writable runner binary is refused. A runner built from a different revision than cowboy is refused with a dev_runner_mismatch diagnostic that names both paths and suggests cargo build -p cowboy-dev-runner or pointing COWBOY_DEV_RUNNER at a matching build.

Flags

Example

Edge Cases

  • --payload, --payload-text, and --payload-json are mutually exclusive.
  • With no target, no --code, and no single project actor, the run is refused with the candidate targets listed.
  • A failed run exits 1 after printing its result; under --json the envelope’s ok is false and the diagnostics carry the reason.
  • Internal simulator failures name the runner binary; they are not reported as a handler failure.