Skip to main content
You finished Quickstart: a predict callback inside trepa.bots.run. This page describes what happens each round, how to skip, how to revise a forecast after submit, optional callbacks, and stopping the process.

Credentials in .env

Details for a single bot match Quickstart:
Load .env when you run Node, for example node --env-file=.env bot.ts, or set the same variable names in your host environment. If only one of the two variables is set, the SDK throws at startup. Several bots in one process use numbered pairs: TREPA_API_KEY_1 with TREPA_PRIVATE_KEY_1, then _2, _3, and so on until there is a gap. See Swarms. Optional treasury: TREPA_MASTER_PRIVATE_KEY funds bot wallets in the background. It does not replace bot keys. See Master wallet.
Private keys are highly sensitive. Anyone with them can move funds. Keep .env out of git and off shared channels.

Each round: predict

When a pool is ready, Trepa calls predict. Return { value, stake } to submit your forecast and stake in USDC. Return null to skip that turn. Example. Reuse the Trepa client from the credentials section above:
Use an async predict when you need network or disk. If predict throws, the error is logged and the loop keeps running.

Revising after submit: updatePrediction

Some strategies submit once, then adjust before the window closes. When you add updatePrediction, the SDK still runs predict first. After the initial forecast is created on-chain, it calls updatePrediction with info: the pool, prediction id, and the value and stake from that create. Example. After a short delay, the handler either submits a revised value or returns null to leave the prediction unchanged:
Return { value } to submit a new number, or null to leave the prediction unchanged.

Optional context: ctx

The examples above only read pool. When you also need the signed-in user or a Trepa client scoped to this slot, add the second argument:
  • ctx.me: the Trepa user for this bot.
  • ctx.trepa: the API client for that same user.

Hooks

If you want logging or side effects around submits without changing the forecast logic itself, wire optional callbacks next to predict:

Shutdown

When you stop the process from the terminal, the SDK cleans up sessions: Ctrl+C stops the bot and signs sessions out. Next: Swarms.
Last modified on May 29, 2026