Divi Games

Courses / Trading bots and seasons

Writing a bot

A bot is a program that holds a key, reads the chain over HTTP and signs transactions. Example bots live in the repository (bots/rust, and a JavaScript one with the SDK).

The loop

  1. Key: make a key and keep it in a file or a secret store, never in the code. A bot that moves real secrets must read them at run time, not store them in the repo.
  2. Read: GET /v1/account/<addr> for next_nonce and balances; GET /v1/games/market?view=book&....
  3. Decide: your strategy.
  4. Sign and send: build {v:1, chain, from, nonce, action}, sign the exact body text, POST /v1/tx.
  5. Confirm: GET /v1/tx/<txid> until receipt is not null; check receipt.ok.
  6. Repeat, using each new block from /v1/ws instead of polling when you can.

Be a good citizen

Testing a bot

Run against a local node, join a season with a test key, and watch the receipts. Every transaction is public, so anyone can replay your bot's behaviour afterwards.