Skip to main content
A Cowboy project is a folder with a cowboy.toml at its root. Every project command (check, test, run, build, deploy, actor ..., workload ...) finds the project by walking up from the current folder to the nearest cowboy.toml, so you can run them from any folder inside it. A project holds one or more actors, and can add off-chain functions and workloads (Where your code runs compares them).

What cowboy init writes

An actor

Output
It writes:
Run cowboy init <name> again inside a project to add another actor next to the first. init keeps the files that are already there.

An off-chain function

Output
Adds the actor actors/fn/ and an offchain/ package beside it:
It also adds an empty [offchain] table to cowboy.toml and sets up a second Python environment for local runs in .cowboy/local/offchain-env/. The function is Python by default; --offchain-runtime node writes a Node function instead.

A workload

Output
Adds:
  • workloads/api/, an empty folder for your service.
  • actors/api_owner/ and tests/test_api_owner.py, the actor that owns the workload, with its tests. --owning-actor <actor> names an existing actor of the project instead; init then writes no route, so add one (such as route = "/*") if the workload should answer at the actor’s URL.
  • A [workloads.api] table in cowboy.toml, which raises schema_version to 6.
--runtime is node, python or rust. Without it, init reads it from a package.json, pyproject.toml or Cargo.toml already in workloads/api/. Run a web app or service continues from here. Add --dry-run to any of these to see the plan without writing files.

What’s in .cowboy/

.cowboy/ holds what the CLI writes as you work. It belongs to your machine, and .gitignore keeps it out of git. Two things are not in the project:
  • Keys. cowboy wallet create keeps your key in ~/.cowboy/keys/default, outside every project, so it never lands in a repository.
  • The remembered environment. init --env, deploy --env and env use record the project’s environment in ~/.cowboy/config.json, by the project’s path.
offchain.lock, which cowboy build writes at the project root for a project with off-chain functions, pins the base its image builds on. Commit it.

cowboy.toml

The manifest init writes for an actor project is one line:
Every other table is optional. The CLI rejects a key it doesn’t know, anywhere in the file, so a typo fails at once instead of being ignored.

schema_version

The CLI reads versions 1 to 7. Each table needs at least the version shown; an older file that uses one is refused with a message naming the version to set: init writes 2, and 6 once the project has a workload.

Actors

Without any [actors] table, each actors/<name>/main.py is an actor named <name>; so is a file actors/<name>.py that defines an Actor subclass. Names are lowercase letters, digits and _, starting with a letter. A project holds at most 64 actors. Declare an actor when its code lives somewhere else:
A command that takes an actor name uses the one you pass, else the actor whose folder you are in, else the project’s only actor.

[offchain]

Settings for the project’s off-chain functions. An empty table uses the defaults.

[web]

Static files for the actor’s website. cowboy deploy publishes the folder to a public storage volume before it deploys the actor, and the actor’s routes serve it. cowboy deploy --web-only republishes the files alone.

[workloads.<name>]

One table per workload. runtime, run and resource_class are required.

[environments]

Per-environment values for a workload’s vars. A value here replaces the one with the same name in [workloads.<name>] when you deploy to that environment:
vars is the only key an environment can override.

A complete example

A project with an actor that owns a workload, off-chain functions, and a static site. cowboy check accepts it:
Output

Next steps

Test your actor

cowboy test, SimulatedChain and cowboy run

Deploy and operate

Environments, wallets, deploys and keeping an actor funded