# Game catalog, live games protocol & reference casinos

BetPlug ships a **continuously expanding catalog of provably-fair house games** across five runtime shapes ([`/api/openapi.yaml`](/api/openapi.yaml), [`/api/asyncapi.yaml`](/api/asyncapi.yaml)): Instant games, Stateful Session games, Originals Slots, shared Live Shows, and per-operator Live Tables. Every game below is **mounted and served by the BetPlug API across `sandbox` and `live`**, executing deterministic fixed-point integer arithmetic with zero floats on money or outcomes.

## 1. Full game catalog & runtime matrix

### Instant games (single-request settle)

Every Instant game settles in one round-trip (`POST /v1/rounds` headless or `POST /v1/session/rounds` embedded) and ships a zero-raster SVG + TypeScript `<betrail-game>` client bundle (`<= 150 KB` gzip) as `@betrail/game-<slug>`:

| `GameSlug` | Engine ID & version | Client bundle | RNG stream, params & availability |
| --- | --- | --- | --- |
| `dice` | `DICE` v1 | `@betrail/game-dice` | `dice-sha512` (`SHA-512(server_seed:client_seed:nonce)`); [`DiceParams`](/docs/api-reference#diceparams) (`direction`, `chance`, `payout`); mounted in the BetPlug API |
| `limbo` | `LIMBO` v1 | `@betrail/game-limbo` | `hmac-nonce` (`HMAC-SHA256(server_seed, client_seed:nonce)`, no `:cursor`, 12-dec `bcdiv` byte sum `S`); [`LimboParams`](/docs/api-reference#limboparams) (`target`); mounted in the BetPlug API |
| `plinko` | `PLINKO` v1 | `@betrail/game-plinko` | `plinko-hmac` (`HMAC-SHA256(server_seed, client_seed:nonce:c)`, `c = 0` for 8 pins / `c = 0, 1` for 9..16 pins); 27 pinned Binomial paytables (`8..16` pins x `LOW`/`MEDIUM`/`HIGH`); [`PlinkoParams`](/docs/api-reference#plinkoparams); mounted in the BetPlug API |
| `roulette` | `ROULETTE` v1 | `@betrail/game-roulette` | `hmac-nonce` (`HMAC-SHA256(server_seed, client_seed:nonce)`, no `:cursor`, 12-dec `bcdiv` byte sum `S`); single-zero 37-pocket wheel; [`RouletteParams`](/docs/api-reference#rouletteparams) (`chips`); mounted in the BetPlug API |
| `diamonds` | `DIAMONDS` v1 | `@betrail/game-diamonds` | `hmac-nonce` (`HMAC-SHA256(server_seed, client_seed:nonce)`, no `:cursor`, 12-dec `bcdiv` byte sum `S`); 5-gem draw across 7 hands; [`DiamondsParams`](/docs/api-reference#diamondsparams) (`{}`); mounted in the BetPlug API |
| `packs` | `PACKS` v1 | `@betrail/game-packs` | `FairRandom`; 5-card booster pack over 242-card table (`RTP = 19/20`); [`PacksParams`](/docs/api-reference#packsparams) (`{}`); mounted in the BetPlug API |
| `range-dice` | `RANGEDICE` v1 | `@betrail/game-range-dice` | `FairRandom`; configurable `[low, high]` interval; [`RangediceParams`](/docs/api-reference#rangediceparams) (`mode`, `target`/`ranges`, `multiplier`); mounted in the BetPlug API |
| `wheel` | `WHEEL` v1 | `@betrail/game-wheel` | `FairRandom`; risk-tiered segment paytables; [`WheelParams`](/docs/api-reference#wheelparams) (`risk`, `segments`); mounted in the BetPlug API |
| `drill` | `DRILL` v1 | `@betrail/game-drill` | `FairRandom`; multi-target depth multiplier; [`DrillParams`](/docs/api-reference#drillparams) (`target`, `pick`); mounted in the BetPlug API |
| `slide` | `SLIDE` v1 | `@betrail/game-slide` | `FairRandom`; target crash-multiplier reel; [`SlideParams`](/docs/api-reference#slideparams) (`target`); mounted in the BetPlug API |
| `cases` | `CASES` v1 | `@betrail/game-cases` | `FairRandom`; weighted mystery-case paytables; [`CasesParams`](/docs/api-reference#casesparams) (`difficulty`); mounted in the BetPlug API |
| `bars` | `BARS` v1 | `@betrail/game-bars` | `FairRandom`; multi-bar reveal grid; [`BarsParams`](/docs/api-reference#barsparams) (`difficulty`, `picks`); mounted in the BetPlug API |
| `keno` | `KENO` v1 | `@betrail/game-keno` | `FairRandom`; Fisher-Yates 10-of-40 draw (`1..10` picks); [`KenoParams`](/docs/api-reference#kenoparams) (`risk`, `picks`); mounted in the BetPlug API |
| `darts` | `DARTS` v1 | `@betrail/game-darts` | `FairRandom`; radial board ring paytables; [`DartsParams`](/docs/api-reference#dartsparams) (`difficulty`); mounted in the BetPlug API |
| `tarot` | `TAROT` v1 | `@betrail/game-tarot` | `FairRandom`; 3-arcana multiplier product; [`TarotParams`](/docs/api-reference#tarotparams) (`difficulty`); mounted in the BetPlug API |
| `baccarat` | `BACCARAT` v1 | `@betrail/game-baccarat` | `FairRandom`; Punto Banco third-card tableau (`player` / `banker` / `tie` + side bets); [`BaccaratParams`](/docs/api-reference#baccaratparams) (`bets`); mounted in the BetPlug API |
| `kaboom` | `KABOOM` v1 | `@betrail/game-kaboom` | `FairRandom`; instant minefield preset sweep (`cap_rule: refuse`); [`KaboomParams`](/docs/api-reference#kaboomparams) (`charge`, `spot`); mounted in the BetPlug API |
| `tilt` | `TILT` v1 | `@betrail/game-tilt` | `FairRandom`; balance-beam multiplier (`cap_rule: refuse`); [`TiltParams`](/docs/api-reference#tiltparams) (`notch`); mounted in the BetPlug API |

### Stateful session games (multi-step `open` -> `/actions`)

Stateful games debit stake once at `POST /v1/rounds` (or `POST /v1/session/rounds`), advance deterministically via `POST /v1/rounds/{id}/actions` (or `/v1/session/rounds/{id}/actions`) with monotonic `step >= 1`, block seed rotation while a round is `open` (`409 round_open`), and settle on cash-out, terminal loss, or `POST /v1/players/{player_ref}/force-close`. Player `do: "force_close"` is always refused (`422 invalid_action`).

| `GameSlug` | Engine ID & version | Availability status | Mechanics & schemas |
| --- | --- | --- | --- |
| `chicken` | `CHICKEN` v1 | **Mounted in the BetPlug API** (`FairRandom`) | Lane-stepping survival ladder (`step`, `cashout`) — [`ChickenParams`](/docs/api-reference#chickenparams) / [`ChickenAction`](/docs/api-reference#chickenaction) |
| `pump` | `PUMP` v1 | **Mounted in the BetPlug API** (`FairRandom`) | Balloon inflation multiplier ladder (`pump`, `cashout`) — [`PumpParams`](/docs/api-reference#pumpparams) / [`PumpAction`](/docs/api-reference#pumpaction) |
| `mines` | `MINES` v1 | **Mounted in the BetPlug API** (`FairRandom`) | 5x5 grid (`1..24` mines; `sweep`, `cashout`; note preset `(12, 11)` returns `409 not_offered`) — [`MinesParams`](/docs/api-reference#minesparams) / [`MinesAction`](/docs/api-reference#minesaction) |
| `towers` | `TOWERS` v1 | **Mounted in the BetPlug API** (`FairRandom`) | Multi-floor climb across difficulty tiers (`sweep`, `cashout`) — [`TowersParams`](/docs/api-reference#towersparams) / [`TowersAction`](/docs/api-reference#towersaction) |
| `blackjack` | `BLACKJACK` v1 | **Mounted in the BetPlug API** (`FairRandom`) | Infinite shoe (`hit`, `stand`, `double`, `split`, `insurance`, `no_insurance`) — [`BlackjackParams`](/docs/api-reference#blackjackparams) / [`BlackjackAction`](/docs/api-reference#blackjackaction) |
| `hilo` | `HILO` v1 | **Mounted in the BetPlug API** (`FairRandom`) | Sequential card higher/lower/skip chain (`guess`, `skip`, `cashout`) — [`HiloParams`](/docs/api-reference#hiloparams) / [`HiloAction`](/docs/api-reference#hiloaction) |
| `snakes` | `SNAKES` v1 | **Mounted in the BetPlug API** (`FairRandom`) | Dice-driven board path with snake hazards (`roll`, `cashout`) — [`SnakesParams`](/docs/api-reference#snakesparams) / [`SnakesAction`](/docs/api-reference#snakesaction) |
| `flip` | `FLIP` v1 | **Mounted in the BetPlug API** (`FairRandom`) | Compounding coin-flip streak (`flip`, `cashout`) — [`FlipParams`](/docs/api-reference#flipparams) / [`FlipAction`](/docs/api-reference#flipaction) |
| `rps` | `RPS` v1 | **Mounted in the BetPlug API** (`FairRandom`) | Multi-step rock-paper-scissors streak (`throw`, `cashout`) — [`RpsParams`](/docs/api-reference#rpsparams) / [`RpsAction`](/docs/api-reference#rpsaction) |
| `moles` | `MOLES` v1 | **Mounted in the BetPlug API** (`FairRandom`) | Whack-a-mole grid survival ladder (`hit`, `cashout`) — [`MolesParams`](/docs/api-reference#molesparams) / [`MolesAction`](/docs/api-reference#molesaction) |
| `video-poker` | `VIDEOPOKER` v1 | **Mounted in the BetPlug API** (`FairRandom`) | 5-card draw + hold (`Jacks or Better`; `draw`) — [`VideopokerParams`](/docs/api-reference#videopokerparams) / [`VideopokerAction`](/docs/api-reference#videopokeraction) |
| `sky-rush` | `SKYRUSH` v1 | **Mounted in the BetPlug API** (`FairRandom`, `cap_rule: refuse`) | Step-by-step altitude cash-out (`fly`, `cashout`) — [`SkyrushParams`](/docs/api-reference#skyrushparams) / [`SkyrushAction`](/docs/api-reference#skyrushaction) |
| `dead-shot` | `DEADSHOT` v1 | **Mounted in the BetPlug API** (`FairRandom`, `cap_rule: refuse`) | Chamber cylinder survival (`fire`, `stop`) — [`DeadshotParams`](/docs/api-reference#deadshotparams) / [`DeadshotAction`](/docs/api-reference#deadshotaction) |
| `meme-kombat` | `KOMBAT` v1 | **Mounted in the BetPlug API** (`FairRandom`, `cap_rule: refuse`) | Single-player fighter duel (`next`, `live_bet`) — [`KombatParams`](/docs/api-reference#kombatparams) / [`KombatAction`](/docs/api-reference#kombataction) |
| `stack-packs` | `STACKPACKS` v1 | **Mounted in the BetPlug API** (`FairRandom`, `cap_rule: refuse`) | Progressive pack-stacking session (`draw`, `cashout`) — [`StackpacksParams`](/docs/api-reference#stackpacksparams) / [`StackpacksAction`](/docs/api-reference#stackpacksaction) |

### Originals slots (single-nonce spin + bonus rounds)

Each Originals Slot runs on `OriginalsSlotEngine`, consuming a single `(server_seed, client_seed, nonce)` commitment per paid spin (including triggered cascades and free-spin bonus rounds):

| `GameSlug` | Engine ID & version | Client package | Bundle asset path |
| --- | --- | --- | --- |
| `grimoire-of-gains` | `GRIMOIRE` v1 | `@betrail/game-grimoire-of-gains` | `/games/grimoire-of-gains/v0.1.0/betrail-grimoire-of-gains.js` |
| `pharaoh-pump` | `PHARAOH` v1 | `@betrail/game-pharaoh-pump` | `/games/pharaoh-pump/v0.1.0/betrail-pharaoh-pump.js` |
| `shogun-shiba` | `SHOGUN` v1 | `@betrail/game-shogun-shiba` | `/games/shogun-shiba/v0.1.0/betrail-shogun-shiba.js` |

All three are mounted in the BetPlug API (`FairRandom`): `params` is `{}` ([`SlotParams`](/docs/api-reference#slotparams)), and the settled `view` is [`SlotView`](/docs/api-reference#slotview).

> **Tip:** New sandbox brands enable the full catalog automatically on onboarding. Existing brands can enable additional games anytime in Console or via `PUT /console/brands/{brand}/games/{environment}` (a disabled brand game returns `409 not_offered`).

### Live multiplayer shows & tables

| `GameSlug` | Engine ID & version | Topology | Money entry route (REST) | Socket commands (`receiveLiveCommand`) | Isolation & policy |
| --- | --- | --- | --- | --- | --- |
| `trapdoor` | `TRAPDOOR` v1 (`ShowEngine`) | Shared environment show | `POST /v1/live/trapdoor/bets` (`createLiveBet`) | `TrapdoorCommand` (`snapshot`, `pick`, `bank`, `plan`) | Zero cross-operator crowd figures |
| `kombat-multiplayer` | `KOMBATMP` v1 (`ShowEngine`) | Shared environment show | `POST /v1/live/kombat-multiplayer/bets` (`createLiveBet`) | `KombatmpCommand` (`snapshot`) | Zero cross-operator crowd figures |
| `crash` | `CRASH` v1 (`ShowEngine`) | Shared environment show | `POST /v1/live/crash/bets` (`createLiveBet`) | `CrashCommand` (`snapshot`, `cashout`) | Zero cross-operator crowd figures |
| `meme-trade` | `MEME_TRADE` v2 (`ShowEngine`) | Shared environment show | `POST /v1/live/meme-trade/buy-ins` (`createMemeTradeBuyIn`) | `LiveCommand` (`snapshot`, `open`, `close`, `sidebet`, `auto_sell`) | Enabled in `sandbox` & `live`; position adds refused; mid-round force-close retired; `OutageVoid` refunds open buy-ins; zero crowd figures |
| `stack-o-pass` | `STACKOPASS` v1 (`Engine` live tables) | **Per-operator** 6-seat lobbies | `POST /v1/session/rounds` (`live_seat: { table, seat }`) | `StackOPassCommand` (`snapshot`, `watch`, `open`, `pass`, `cashout`, `leave`) | Per-operator tables; per-player `FairRandom` seeds |

---

## 2. Live games protocol & WebSocket state machine

Live WebSocket channels, commands, and settlement frames are specified in [`/api/asyncapi.yaml`](/api/asyncapi.yaml).

> **Warning:** Live multiplayer games (`trapdoor`, `kombat-multiplayer`, `stack-o-pass`, `crash`, `meme-trade`) **always require a real player session backed by a seamless wallet** (`mode: "real"`). Demo sessions are refused on live tickets and live bets with `403`.

### Live WebSocket state machine

```text
[1] POST /v1/launch (mode:"real") -> [2] POST /v1/sessions (bts_<token>)
                                              |
                                              v
[3] POST /v1/live/{game}/tickets (0-byte body, Idempotency-Key) -> 30 s single-use ticket
                                              |
                                              v
[4] WS wss://live.betrail.example/v1/live/{game}  [Sec-WebSocket-Protocol: betrail.v1, ticket.<ticket>]
                                              |
    +-----------------------------------------+-----------------------------------------+
    |                                         |                                         |
    v                                         v                                         v
SNAPSHOT (seq: 1)  --->  WAITING (lobby)  --->  ACTIVE (ticks / commands)  --->  SETTLED (LiveSettledFrame)
 (or on seq gap:         (stakes enter        (crash cashout, trapdoor          + seed revealed / skipped_link
  send snapshot cmd)      via REST POST)       pick/bank, meme-trade trades)    + round.settled webhook
```

### Concrete live WebSocket frames (`snapshot`, `tick`, `settled`, `skipped_link`)

Every server frame uses the [`LiveFrame`](/docs/api-reference#liveframe) envelope (`type`, `game`, `seq`, `at`, plus optional `request_id` and `data`). Below are schema-valid [`CrashFrame`](/docs/api-reference#crashframe) examples (`CrashProjectedSnapshot`, `CrashTickFrame`, `CrashSettlement` carrying `CrashResultBeforeReveal`) and a [`MemeTradeFrame`](/docs/api-reference#memetradeframe) [`MemeTradeSkippedLink`](/docs/api-reference#memetradeskippedlink) broadcast from [`/api/asyncapi.yaml`](/api/asyncapi.yaml):

```json tab=snapshot
{
  "type": "snapshot",
  "game": "crash",
  "seq": 1,
  "at": 1793238301300,
  "data": {
    "show": {
      "type": "snapshot",
      "show": {
        "type": "lobby",
        "chain": "crash-main-01",
        "index": 1042,
        "commit": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
        "salt": "00000000000000000001e3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4",
        "salt_source": "bitcoin:870000",
        "lobby_closes_at": 1793238300000
      },
      "phase": "ACTIVE",
      "step": 14,
      "tick": 13,
      "multiplier": "1.08",
      "elapsed_ms": 1300
    },
    "self_bets": [
      {
        "bet_id": "bet_01jbx7q2w3e4r5t6y7u8i9o0pa",
        "currency": "BTC",
        "stake": "0.00100000",
        "settled": false
      }
    ]
  }
}
```

```json tab=tick
{
  "type": "tick",
  "game": "crash",
  "seq": 15,
  "at": 1793238311600,
  "data": {
    "type": "tick",
    "tick": 116,
    "multiplier": "2.00",
    "elapsed_ms": 11600
  }
}
```

```json tab=settled
{
  "type": "settled",
  "game": "crash",
  "seq": 42,
  "at": 1793238311650,
  "data": {
    "bet_id": "bet_01jbx7q2w3e4r5t6y7u8i9o0pa",
    "currency": "BTC",
    "stake": "0.00100000",
    "payout": "0.00200000",
    "refund": "0.00000000",
    "settled_by": "play",
    "view": {
      "chain_id": "crash-main-01",
      "round_index": 1042,
      "ended_by": "CASHED_OUT",
      "reason": "MANUAL",
      "auto_cashout": null,
      "cap_multiplier": "1001.00",
      "settled_step": 117,
      "at_tick": 116,
      "elapsed_ms": 11600,
      "multiplier": "2.00",
      "seed_revealed_at_settle": false
    }
  }
}
```

```json tab=skipped_link
{
  "type": "skipped_link",
  "game": "meme-trade",
  "seq": 43,
  "at": 1793238320000,
  "data": {
    "type": "skipped_link",
    "link": {
      "chain": "mt-main-01",
      "index": 1042,
      "commit": "113459eb7bb31bddee85ade5230d6ad5d8b2fb52879e00a84ff6ae1067a210d3",
      "salt": "00000000000000000001e3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4",
      "salt_source": "bitcoin:870000"
    },
    "serverSeed": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",
    "tick": 1842
  }
}
```

### Step-by-step handshake, betting & settlement details

1. **Mint a `real` launch credential (`POST /v1/launch`)** and exchange it in the browser (`POST /v1/sessions`) for `bts_<token>` (kept strictly in closure memory).
2. **Mint a 30-second single-use join ticket (`POST /v1/live/{game}/tickets`):** Send `Authorization: Bearer bts_…`, a fresh `Idempotency-Key`, and a **0-byte empty body**. Returns `201 { ticket: "v1.<payload>.<mac>", url: "wss://live.betrail.example/v1/live/{game}", expires_at }`. The live server verifies HMAC and `Origin` first (`null` refused `403 origin_not_allowed`) and consumes `jti` last so rejected handshakes do not burn the ticket.
3. **Upgrade via `Sec-WebSocket-Protocol` (`joinTicket` scheme):** Connect with `new WebSocket(url, ["betrail.v1", "ticket." + ticket])`. Access logs scrub `Sec-WebSocket-Protocol` so tickets never leak; the server echoes `betrail.v1` only.
4. **Gap recovery:** Every frame carries monotonic `seq`. On any gap, send `{ "type": "snapshot", "request_id": "req_01" }` (`LiveCommand` requires `["type", "request_id"]` with `additionalProperties: false`).
5. **REST money entry & outbox settlement:**
   - **Shared shows (`trapdoor`, `kombat-multiplayer`, `crash`):** Stakes enter over REST via `POST /v1/live/{game}/bets` (`{ show, stake, params }`, `Idempotency-Key`), debiting `<bet_id>:0:<attempt>:debit` and crediting `<bet_id>:credit` on settlement.
   - **`MEME_TRADE` v2 (`meme-trade`):** Buy in over REST via `POST /v1/live/meme-trade/buy-ins` (`{ round, amount }`, `Idempotency-Key`, debiting `<show_round_id>:<player_ref>:b<buyIn>:<attempt>:debit`). In-round commands (`open`, `close`, `sidebet`, `auto_sell`) travel over WebSocket under the **tick barrier**. Position adds are refused, mid-round force-close retired (`POST /v1/players/{player_ref}/force-close` returns `200 {"rounds":[],"pending":0}` without touching `MEME_TRADE`; `PUT /v1/players/{player_ref}/status` revokes live sessions immediately; post-rug outbox credits run unconditionally; writer outages refund open buy-ins via `OutageVoid`).
   - **`STACKOPASS` (`stack-o-pass`):** Buy into a per-operator 6-seat table via `POST /v1/session/rounds` (`{ stake, params, live_seat: { table, seat } }`), play `open`/`pass`/`cashout` over WebSocket, and settle per hand via `<round_id>:credit`.
   - **Unified `LiveSettlement` (`LiveSettledFrame`):** Emits `{ bet_id, currency, stake, payout, refund, settled_by: "play" | "force_close" | "outage", view }` over the socket alongside the signed `round.settled` webhook.

### Demo and replay in the embedded live clients

Live games ship embedded clients: `crash`, `kombat-multiplayer`, `meme-trade`, `trapdoor` and `stack-o-pass` (`@betrail/game-<slug>`). `<betrail-game mode="demo">` for one of them needs no token and no session: it runs a simulated show in the browser (a simulated table for `stack-o-pass`) using a local seed chain (local seeds for `stack-o-pass`), the verifier's own maths, and a fake balance of `1000.00000000 DEMO`. It opens no socket, mints no ticket, places no bet, and sends no record anywhere.

For these clients the element asks for no demo session: each client declares that its demo needs none, so the element sends no `POST /v1/demo/sessions`, on any origin. Nothing is refused, so the host bridge receives no error event, and the `stack-o-pass` cockpit displays only the simulated table's state. This behaves identically on an operator's origin and on BetPlug's (note that `POST /v1/demo/sessions` accepts only BetPlug's own site origins and returns `403 origin_not_allowed` on an operator's origin; Instant, Stateful, and Slot games still use it in demo mode).

The stage and phase bar display a badge, and after each simulated bet settles, the client replays it locally in the browser, never a server record:

| Client | Badge | Demo verdict |
| --- | --- | --- |
| `crash` | `DEMO (simulated show)` | `DEMO: the simulated bet replays from its revealed seed (no server record)` |
| `kombat-multiplayer` | `DEMO (simulated show)` | `DEMO: the simulated bet replays from its revealed seed (no server record)` |
| `meme-trade` | `DEMO (simulated show)` | `DEMO: the simulated round replays from its revealed seed (no server record)` |
| `trapdoor` | `DEMO (simulated show)` | `DEMO: the simulated bean replays from its revealed seed (no server record)` |
| `stack-o-pass` | `DEMO (simulated show)` | `DEMO: the simulated hand replays from its revealed seed (no server record)` |

On an operator's origin, set `mode="demo"` with no `token`: `POST /v1/launch` with `mode: "demo"` for a live game returns `409 not_offered` ("This live game has no demo play.").

`<betrail-game mode="replay" token="..." round-id="...">` exchanges the launch token, reads one settled round record (`GET /v1/session/rounds/{id}`), and replays it without opening a socket. A live show bet becomes readable once its show reveals its seed (`404` before then), displaying `VERIFIED MATCH (replay)` with chain anchor unanchored. A `stack-o-pass` hand replays once the player's seed pair rotates.

### Provable fairness & zero cross-operator crowd leakage

- **Reverse hash chains (`TRAPDOOR`, `KOMBATMP`, `CRASH`, `MEME_TRADE`):** Each shared show pre-commits the terminal digest of a reverse `SHA-256` hash chain (`link_{k} = SHA256(link_{k+1})`) combined with an external block beacon published before betting opens, disclosing unused links via `skipped_link`.
- **Zero cross-operator crowd figures:** Shared shows emit **zero** `round_totals`, **zero** aggregate player counts, and **zero** cross-player bet frames so no operator can subtract its own share to infer competitors' volume. `stack-o-pass` isolates tables strictly per operator.

---

## 3. Reference casinos (`examples/`)

Three end-to-end reference casinos in the repository demonstrate headless REST play, `<betrail-game>` / iframe embedding, `WalletHandler` with Ed25519 answer signing, and raw-body webhook verification:

| Reference casino | Stack & SDK | Highlights |
| --- | --- | --- |
| `./examples/next-casino` | Next.js + TypeScript (`./sdk/ts`) | Server-side `BetrailClient`, `createWalletHandler` with Ed25519 answers, raw-byte `verifyWebhook`, `<betrail-game>` + `betrail:v1` host bridge, strict nonce CSP, zero raster assets. |
| `./examples/go-casino` | Go 1.27 `net/http` + `html/template` (`./sdk/go`) | Zero third-party dependencies, `betrail.NewClient`, `betrail.NewWalletHandler` (`GenerateEd25519WalletKeyPair` + `FileBackedNonceStore`), `betrail.VerifyHTTPWebhook` over `r.RequestURI`, SVG-only UI. |
| `./examples/laravel-casino` | PHP 8.2+ / Laravel-style (`./sdk/php`) | `Betrail\Sdk\Client`, `WalletHandler` (`Ed25519::generateWalletKeyPair` + `FileBackedWalletBook` + `FileBackedNonceStore`), `Webhooks::verify` over raw `php://input` and `$_SERVER['REQUEST_URI']`, strict CSP iframe launch. |

Each reference casino mounts representative games (`dice`, `packs`, `wheel`) and ships an end-to-end local-stack integration test suite.

## 4. Building join-ticket protocols & handling live frames (runnable sample)

```ts
import assert from "node:assert/strict";
import crypto from "node:crypto";

function buildLiveProtocols(ticket: string): [string, string] {
  assert.match(ticket, /^v1\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/, "expected signed v1 join ticket");
  return ["betrail.v1", `ticket.${ticket}`];
}

const protocols = buildLiveProtocols("v1.eyJzaWQiOiJzZXNzXzAxIn0.c2lnbmF0dXJl");
assert.deepEqual(protocols, ["betrail.v1", "ticket.v1.eyJzaWQiOiJzZXNzXzAxIn0.c2lnbmF0dXJl"]);

// Gap recovery commands carry "request_id" and CrashFrame settlements carry LiveFrame + CrashResultBeforeReveal
const snapshotCmd = { type: "snapshot", request_id: "req_01" } as const;
assert.deepEqual(Object.keys(snapshotCmd).sort(), ["request_id", "type"]);

const settledFrame = {
  type: "settled" as const,
  game: "crash" as const,
  seq: 42,
  at: 1793238311650,
  data: {
    bet_id: "bet_01jbx7q2w3e4r5t6y7u8i9o0pa",
    currency: "BTC",
    stake: "0.00100000",
    payout: "0.00200000",
    refund: "0.00000000",
    settled_by: "play" as const,
    view: {
      chain_id: "crash-main-01",
      round_index: 1042,
      ended_by: "CASHED_OUT" as const,
      reason: "MANUAL" as const,
      auto_cashout: null,
      cap_multiplier: "1001.00",
      settled_step: 117,
      at_tick: 116,
      elapsed_ms: 11600,
      multiplier: "2.00",
      seed_revealed_at_settle: false as const,
    },
  },
};
assert.ok(["play", "force_close", "outage"].includes(settledFrame.data.settled_by));
assert.equal(settledFrame.data.view.elapsed_ms, settledFrame.data.view.at_tick * 100);
assert.equal(settledFrame.data.view.seed_revealed_at_settle, false);

// Verify MemeTradeSkippedLink commitment: sha256_hex(serverSeed) === link.commit
const skippedLink = {
  type: "skipped_link" as const,
  game: "meme-trade" as const,
  seq: 43,
  at: 1793238320000,
  data: {
    type: "skipped_link" as const,
    link: {
      chain: "mt-main-01",
      index: 1042,
      commit: "113459eb7bb31bddee85ade5230d6ad5d8b2fb52879e00a84ff6ae1067a210d3",
      salt: "00000000000000000001e3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4",
      salt_source: "bitcoin:870000",
    },
    serverSeed: "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",
    tick: 1842,
  },
};
const computedCommit = crypto.createHash("sha256").update(skippedLink.data.serverSeed, "utf8").digest("hex");
assert.equal(computedCommit, skippedLink.data.link.commit);
```
