Skip to main content
By the end of this page, you’ll know where each part of an existing script or service goes on Cowboy, and you’ll have seen a cron script turned into an actor that does the same job on its own. Most of your logic carries over as it is. What changes is the edges: how the code is started, how it reaches the network, where it keeps its keys, and where it stores what it learns.

Where each part goes

An actor holds the rules and the records, and it runs the same way on every machine that checks it. That’s why it can’t reach the network, read the clock or open a file itself. A runner, a machine that does work for actors, makes those calls for it and hands back the answer. Where your code runs explains the last two.

Before: a cron script

Here’s a typical starting point. Once an hour, cron runs a script that reads a key from the environment, asks an API for an account’s follower count, and appends it to a file:
It needs a machine that stays on, a crontab entry, and the key on that machine. Sorted with the table above:
  • cron becomes @every(HOUR)
  • requests.get becomes runner.http
  • os.environ["EXAMPLE_API_KEY"] becomes runner.secret("EXAMPLE_API_KEY", ...)
  • counts.json becomes the actor’s state
  • ACCOUNT becomes state too, set by a handler only the owner can call

After: an actor

Create a project next to your code with cowboy init follower_tracker, and replace actors/follower_tracker/main.py with:
The logic is the same. What moved:
  • Starting it. track sets the account and starts the hourly schedule. After that, check runs every hour with nothing on your side, and the actor pays for each run from its balance.
  • The request. await runner.http(...) hands the request to a runner, and check picks up from the same line when the answer arrives. The time comes from runtime.get_timestamp_ms(), not time.time().
  • The key. It’s in the secret store, and the job carries only "Bearer " and the key’s name (Call an API with a key).
  • The file. counts lives in the actor’s state, which anyone can read and anyone can query through the counts handler. Keep private data in a private volume instead (An actor’s files).
Some code carries over only after a change. A handler can’t loop over awaits, so a script that calls an API once per item either makes one call that returns them all, or handles one item per run. And code that depends on randomness or the current time has to get them from the SDK (What actor code can and can’t do).

Test it the same way

Your old tests probably mocked requests. On Cowboy, a test plays the API’s part: it moves time forward, sees the job the actor sent, and answers it. Replace tests/test_follower_tracker.py with:
Output
chain.advance_block(3600) moves time forward an hour, about one second a block, so the schedule fires once.

Then ship it

From here, it’s the same path as any actor: deploy it with the API’s host in its manifest, add the key, then package and submit it. The walkthrough shows each step.

Next