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
- 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.
- Read:
GET /v1/account/<addr>fornext_nonceand balances;GET /v1/games/market?view=book&.... - Decide: your strategy.
- Sign and send: build
{v:1, chain, from, nonce, action}, sign the exact body text,POST /v1/tx. - Confirm:
GET /v1/tx/<txid>untilreceiptis not null; checkreceipt.ok. - Repeat, using each new block from
/v1/wsinstead of polling when you can.
Be a good citizen
- Track your own nonce and increment it locally; a failed order still uses a nonce.
- Cancel stale orders, so escrow does not stay locked.
- Respect rate limits and the mempool (
503means it is full). - Treat a
409(duplicate) as already sent.
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.