TOOLING · REFERENCE WALLET

Sandbox wallet

A runnable in-memory wallet implementing the wallet contract — including the unhappy paths. Point your handlers at it and exercise the full cycle in minutes.

LAST UPDATED 2026-07-27

Install & run

npm install https://docs.fidra.tech/pkg/fidra-sandbox-wallet-0.1.0.tgz
npx fidra-sandbox-wallet                        # → http://localhost:4800

The tarball is the canonical distribution channel (works with npm, pnpm and yarn; Node ≥ 18; zero runtime dependencies). Verify the download if your policy requires it:

shasum -a 256 fidra-sandbox-wallet-0.1.0.tgz
# 0ffc7c736f0c45af3979304f99694387f209009cf692268c1e8da499a0879f51

In-memory, zero-dependency, not for production. Wire it into your host page: answer bet_intent by POST /bet, reply fidra:v1:bet_result with the JSON; same for settle_intentPOST /settle.

Endpoints

method · pathbodyreturns
POST /bet{ playerId, roundId, gameId?, amount }{ ok, roundId, balance?, reason? }
POST /settle{ playerId, roundId, gameId?, payout }same shape — payout: 0 on a loss
POST /rollback{ roundId }void an un-settled bet; refuses settled/already-rolled-back rounds
GET /balance?playerId=p1{ playerId, balance }
POST /admin/fail{ mode }set a failure mode (below)
POST /admin/resetclear balances + rounds + fail mode
GET /health{ ok, failMode }

What it enforces — the contract's load-bearing parts

Force the failure cases

modeeffectexercises
nonenormalhappy path
insufficient/betok:false, reason:insufficient_funds, no debitdeclined bet
reject/betok:false, reason:rejectedgeneric decline
timeoutdelays 3500ms — past the feed's 3000ms budgetclient timeout → retry with the same roundId → idempotent replay
error500HTTP 500 on /bet & /settlewallet backend down
curl -XPOST localhost:4800/admin/fail -d '{"mode":"timeout"}'
curl -XPOST localhost:4800/bet -d '{"playerId":"p1","roundId":"r1","amount":50}'   # hangs 3.5s
curl -XPOST localhost:4800/admin/fail -d '{"mode":"none"}'

Every mode is also settable per-request with ?fail=<mode> on /bet and /settle.

source of truth: packages/sandbox-wallet/README.md fidra is a B2B software supplier — no gambling services operated, no player funds held. g.jgerenaia@tomsons.co