Integrate BetPlug with Claude Code or by hand
The BetPlug plugin for Claude Code builds a signed sandbox integration in your own codebase: wallet, webhooks, games and tests. The same steps work by hand with the SDKs for TypeScript, Go, Python and PHP.
# from your local copy of the BetPlug source
$ claude --plugin-dir ./claude-plugin
# then, inside Claude Code
> /betrail-integrate
# step 1 of 7 — writing .env.example
- 1.Writes .env.example
- 2.Signs every request
- 3.Mounts your wallet routes
- 4.Mounts your webhook receiver
- 5.Wires the games
- 6.Checks fairness end to end
- 7.Runs the tests
Step 1 of 7 · .env.example
BETRAIL_API_BASE_URL=
BETRAIL_BRAND_ID=
BETRAIL_API_KEY=
BETRAIL_SIGNING_SECRET=
BETRAIL_WALLET_SECRET=
BETRAIL_WEBHOOK_SECRET=
Three steps to your first sandbox round
Test keys come from the console. The plugin is not published yet: it is on no public registry, and until it is, it loads from a local copy of the BetPlug source.
Create your account (now)
Sign up in the console. You get a test API key and its signing secret, shown once.
Load the plugin (not yet)
Point Claude Code at the plugin directory, or add it as a local marketplace.
Terminalclaude --plugin-dir ./claude-pluginInside Claude Code/plugin marketplace add ./claude-plugin /plugin install betrail@betrailRun the integration (not yet)
In your project, start the guided build. It never takes a secret as an argument.
Inside Claude Code/betrail-integrate
What the integration builds
/betrail-integrate runs seven steps in this order; the last runs the tests that hold the others in place.
Writes .env.example
The names of your API key and secrets, without their values. No secret is written to source or to git.
Signs every request
HMAC-SHA256 over the method, path, time, a one-time nonce and the body, tested against published vectors.
Mounts your wallet routes
Balance, debit, credit and rollback, each keyed on the transaction id, with the right answer for every refusal.
Mounts your webhook receiver
Checks the signature on the raw body before reading it, and drops repeats by their id.
Wires the games
A launch token for the embedded client, or rounds from your server, with amounts as exact decimal strings.
Checks fairness end to end
Rotates a player’s seeds and verifies a settled round against its record.
Runs the tests
Bad signatures, replayed nonces, retried requests, refused rollbacks and a verified round.
Check the plugin before you load it
Load it only from a copy of the BetPlug source, never from a registry or a marketplace that claims to be BetPlug, and compare these values with its manifest first.
- It ships no hooks, so it never runs a shell command on its own.
- Its MCP tools sign in with your console account and reach sandbox only. You approve their access and can revoke it under Security.
- Test keys only: a live key never goes to an agent.
- Plugin directory
./claude-plugin- Install name
betrail@betrail- Plugin version
0.1.0- MCP server
https://mcp.betrail.example/mcp- MCP address in the plugin
${BETRAIL_MCP_URL:-https://mcp.betrail.example/mcp}- MCP package
@betrail/mcp 0.2.0- Guide
https://betrail.example/docs/claude-code
Or build it by hand
SDKs for TypeScript, Go, Python and PHP and reference casinos in Next.js, Go and Laravel exist, but like the plugin they are not published yet. The guides describe every call, so you can build against the API directly today.
- Get your first roundKeys, a signed call and a settled round in sandbox.
- Sign requestsThe signature every call and answer carries.
- Build your walletThe four routes the games call and how retries work.
- Receive webhooksSettled rounds and credit alerts, signed and deduplicated.
- Embed a gameLaunch tokens, the game tag and the play frame.
- Check fairnessSeeds, rotation and replaying a round yourself.
- API referenceEndpoints, request schemas, error codes and per-game parameters.
- Live shows and catalogShared shows, live tables and the real-time protocol.
- SDKs and MCPClient libraries for TypeScript, Go, Python and PHP.