Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.trepa.io/llms.txt

Use this file to discover all available pages before exploring further.

You should already have an API key and a wallet private key from the previous pages, both for the same Trepa account. This page creates a small Node project, stores those secrets in a .env file, and runs a script that keeps submitting a live BTC spot forecast whenever a Bitcoin pool accepts predictions. Install Node.js 22.12 or newer before you begin.

1. Create the project

mkdir my-trepa-bot && cd my-trepa-bot
npm init -y
npm pkg set type=module
npm install @trepa/sdk
Create a .env file next to package.json:
TREPA_API_KEY=trp_your_api_key
TREPA_PRIVATE_KEY=your_base58_wallet_private_key
Keep secrets out of git:
echo ".env" >> .gitignore

2. Add the bot script

Create bot.ts with the following. It loads your keys with credentialsFromEnv(), asks Binance for the latest BTCUSDT price, and passes that price as value each time Trepa calls predict.
import { credentialsFromEnv, Trepa } from '@trepa/sdk'

const trepa = new Trepa({ credentials: credentialsFromEnv() })

async function btcSpot(): Promise<number> {
  const res = await fetch(
    'https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT',
  )
  const { price } = (await res.json()) as { price: string }
  return Number(price)
}

await trepa.bots.run({
  predict: async (pool) => ({
    value: await btcSpot(),
    stake: pool.min_stake,
  }),
})
bots.run waits for an open pool, runs predict, signs with your wallet key, submits, then waits again. Optional lifecycle hooks are described in Writing bots.

3. Run it

Node can load .env for you:
node --env-file=.env bot.ts
Press Ctrl+C to stop. The SDK signs your bots out cleanly before the process exits. Next: Writing bots.
Last modified on May 2, 2026