Overview
Ringside is an in-play exchange on a one-on-one duel that runs entirely onchain. Two fighters (people or AI) play a 90-second top-down fight; spectators buy and sell shares that pay 1.000 test-dollar if their corner wins. The fight and the order book live in the same MagicBlock ephemeral rollup, so the instruction that advances the fight also re-prices the book.
Sportsbooks stream 5–8 seconds behind the action and freeze markets because faster watchers trade on prices that have not seen the latest point. That is courtsiding. Ringside closes the gap instead of policing it: every order carries the tick it was priced on, and an order more than two ticks behind the book is rejected by the program.
Everything runs on Solana devnet with a test-dollar token. No real money is involved.
Quickstart
- 01
Watch and trade
Open a live match from tonight's card. Connect a devnet wallet, approve one session (two hours, scoped to Ringside), then buy red or blue. Each fill shows the tick it was priced on.
- 02
Fight
Go to Fight and take on the PPO fighter. WASD or the on-screen stick to move, click or tap to fire, Space to dash, Shift to shield. Your inputs land onchain every tick.
- 03
Verify
Open any finished match's replay and press Verify. Your browser re-runs the fight in WASM from its inputs and VRF seeds and compares every link of the hash chain.
The tick
A crank calls tick every 100 ms. One tick, in one instruction:
- 01 · time gate: at least one slot since the last tick, and game time never ahead of wall time by more than one second
- 02 · step the shared integer simulation with both fighters' latest inputs (Q16.16, no floats)
- 03 · spawn the power-up wave from its VRF seed when due
- 04 · state_hash = sha256(previous ‖ tick ‖ canonical state)
- 05 · 16 features → integer logistic model → sigmoid table → calibration table → quotes with spread and inventory skew
- 06 · last_priced_tick = tick
The same simulation is compiled to the program, to WASM for the browser and to Python for training; 10,000 random episodes give identical hash chains in all three.
The freshness window
Every trade passes seen_tick, the tick of the quote the trader acted on. If the book has moved on by more than 2 ticks (200 ms) the program rejects the order with ErrStaleTick. Nothing fills and nothing moves. A client re-quotes from a fresh read and sends again.
After a hit in lethal range, quotes freeze for a few ticks (ErrFrozen) so nobody trades into a knockout that is already decided.
Two books
Each match has two markets with identical rules except their price source. The Ringside book is priced inside the tick. The TV-delay book is fed by a relay with the state from delay_ms ago, the way a sportsbook priced off a broadcast would be. The courtsider bot sends the same stale order to both; the difference is the evaluation (E1) shown on Proof.
Pricing
A LightGBM teacher trained on 200,000 simulated matches is distilled into a logistic student, calibrated with a 64-knot isotonic table and stored onchain as Q32.32 integers. The tick evaluates it with a 1,024-entry sigmoid table. The mid is the win probability; the spread depends on time left and inventory skews the quotes so the house's worst case stays under its exposure cap (ErrExposure).
Sealed positions
Positions live on the TEE validator with an ephemeral permission whose members are the owner and the house. Anyone else, including the opposing fighter and clients without a valid token, reads nothing. At settlement reveal_positions flips them public. Clients authenticate to the TEE RPC by signing a challenge; only the token goes in the URL.
Settlement and the record
When the fight ends the crank's settle pays the fighters from the escrow and settles both books. Positions are revealed and claims pay winning shares from the house vault. finalize commits the books to Solana with a Magic Action that writes a MatchRecord: winner, ticks, final hash and both books' totals. Anyone can compare that hash with a replay.
Randomness
Every 15 seconds a wave of power-ups spawns from a seed requested from MagicBlock's VRF on the rollup's queue. The callback is accepted only from the VRF program identity, and the seed is part of the hashed state, so replays reproduce the waves exactly.
Architecture
Solana devnet
Config, ModelParams, Profiles, MatchRecords; accounts before delegation; the token mint and vault.
Private ER (devnet-tee)
Match (public), two Markets (public), Positions (private until reveal), token accounts; crank, VRF queue.
Off-chain
Rust indexer (account subscriptions → Postgres → REST/SSE), the Next.js web app with the WASM sim, and the bots (PPO fighters, spectators, courtsider, delay relay).
Every account a trade or a tick writes is delegated to the same TEE validator, because only accounts on one validator can change together in one rollup transaction, and privacy needs the TEE.
MagicBlock primitives
- Ephemeral Rollup
- The fight, both books and every fill change in one rollup state, ten times a second.
- Without it: Ticks and fills would land at L1 speed and the price could not keep up with the fight.
- Private ER (TEE)
- Positions are sealed by per-account permissions inside a TEE until settlement reveals them.
- Without it: Anyone could read open positions and trade against them mid-fight.
- VRF
- Power-up waves come from verifiable randomness requested on the rollup every 15 seconds.
- Without it: Wave layouts would be predictable or chosen by the operator.
- Crank (ScheduleTask)
- The validator runs tick and settle every 100 ms. No server drives the game.
- Without it: The fight would advance only when someone paid to push it.
- Session keys
- One wallet approval, then two hours of trades and inputs without pop-ups, scoped to Ringside.
- Without it: A wallet pop-up for every punch and every trade.
- Ephemeral SPL
- Stakes, the house vault and payouts move as token balances inside the rollup.
- Without it: Every payout would wait for an L1 transfer.
- TEE RPC + token auth
- Clients reach the validator holding the accounts with a signed token, and only see what they may.
- Without it: Clients would hard-code endpoints and could not read private state.
- Magic Actions
- At the bell the commit to Solana also writes a MatchRecord receipt in the same action.
- Without it: No durable record of the result and the final state hash on Solana.
Program reference
Program id 4efktEjqvfqi5UpmStUmvHmhJ9yFcKNvpZRJw56t5Kej (Anchor 1.0). The IDL and TypeScript builders are in packages/client.
SETUP (ADMIN)
- initialize_config
- Creates the Config: admin, mint, fee and spread parameters, the stale-tick limit and the model version.
- update_config · set_spread_params · pause
- Adjusts parameters or pauses new matches and trades.
- create_model · set_model_params · finalize_model
- Uploads the integer pricing model (4,744 bytes) in chunks and freezes it; matches only price with a finalized model.
- init_house_vault · topup_house_vault · withdraw_fees
- The house's token account on the rollup (owned by the Config PDA), its funding and fee withdrawal.
MATCH LIFECYCLE
- create_profile · delegate_profile
- A fighter's profile (Elo, record) on Solana, delegated to the TEE validator.
- create_match
- Creates the Match and both Markets (Ringside and TV-delay) with the stake, the opponent slot and the stream delay.
- delegate_match · delegate_escrow
- Hands the Match, Markets and the stake escrow to the TEE validator.
- join_fight
- A fighter stakes and takes a corner; the second join rings the bell.
- submit_input
- A fighter's movement, aim and abilities for the next tick (sequence-checked, one per tick).
- schedule_tick
- Schedules the crank: tick then settle every 100 ms, task id = hash(program ‖ match).
- tick
- Steps the duel, extends the hash chain, re-prices the Ringside book and records the tick. Permissionless and time-gated.
TRADING
- join_position · delegate_position · init_position_permission
- A spectator's Position per market, delegated, and its permission (owner + house) set private.
- trade
- Buy or sell shares of a corner at the book's price. Carries seen_tick and a limit price; rejects stale ticks, fighters and limit breaches.
- relay_delayed_state
- Feeds the TV-delay book the state from delay_ms ago (the control book for the A/B).
RANDOMNESS
- request_wave_randomness
- Requests the VRF seed for the next power-up wave on the rollup's queue, once per wave.
- vrf_callback
- Called by the VRF program's identity only: writes the seed and the wave index into the sim.
SETTLEMENT
- settle
- After the final tick: pays the fighters from the escrow, settles both books and reveals positions passed with it.
- reveal_positions
- Flips sealed positions to public (the authority stays a member).
- claim
- Pays a position's winning shares from the house vault.
- finalize · commit_match · cleanup_positions
- Commits the books and the Match to Solana; the Magic Action calls write_match_record; positions are committed and undelegated in batches.
- write_match_record
- Magic Action target: writes the MatchRecord (winner, ticks, final hash, both books' totals) on Solana.
ACCOUNTS
- Config · admin, mint, parameters, model version
- ModelParams · the integer model blob and its metrics hash
- Profile · a fighter's Elo and record
- Match · stake, fighters, the 832-byte sim state, inputs, hash chain, status
- Market ×2 · quotes, inventory, house cash, counters, delay, mode
- Position · a spectator's shares and cost basis per market, private until reveal
- MatchRecord · the result written on Solana at finalize
Errors
| CODE | NAME | MEANING |
|---|---|---|
| 6000 | ErrStaleTick | Fill priced off a stale tick |
| 6001 | ErrFighterBarred | Fighters and their session keys cannot trade their own match |
| 6002 | ErrSlippage | Price is worse than the limit |
| 6003 | ErrExposure | House exposure cap would be exceeded |
| 6004 | ErrClosed | Market or match is not open |
| 6005 | ErrNotFighter | Signer is not a fighter in this match |
| 6006 | ErrBadSeq | Input sequence must increase and inputs are limited to one per tick |
| 6007 | ErrTooEarly | Too early: time gate not reached |
| 6008 | ErrBadQueue | Wrong VRF queue or request |
| 6009 | ErrPaused | Paused |
| 6010 | ErrMath | Arithmetic error |
| 6011 | ErrAlreadySettled | Already settled |
| 6012 | ErrFrozen | Quotes are frozen after a lethal-range hit |
| 6013 | ErrInsufficientShares | Not enough shares to sell |
| 6014 | ErrBadQty | Quantity is zero or above the per-trade maximum |
| 6015 | ErrUnauthorized | Unauthorized |
| 6016 | ErrInvalidAccount | Invalid account |
| 6017 | ErrMatchFull | Match is full or the opponent is reserved |
| 6018 | ErrModel | Model is not finalized or has a bad layout |
| 6019 | ErrNotSettled | Not settled yet |
| 6020 | ErrWrongMode | Wrong market mode for this instruction |
Indexer API
The indexer follows the rollup and Solana and serves what the web app shows. On the private rollup it follows each live match by account subscription: transaction logs there are visible only to their signer, so fills are derived from the public market accounts and the trader shows as private.
- GET /health
- Liveness.
- GET /matches?limit=N
- Recent matches with status, fighters, tick and both books.
- GET /matches/{id}/state
- The latest Match and both Market snapshots.
- GET /matches/{id}/replay
- Every tick's inputs, hash and fair price, the VRF seeds and the fills: what /replay verifies.
- GET /judge/{id}
- The A/B for one match: fills and rejections on each book.
- GET /stats
- Counts, tick cadence, quote age and submit-to-confirm latencies.
- GET /leaderboard
- Fighters by Elo.
- GET /events
- Server-sent events: every tick, fill, rejection and state change as it happens.
- POST /latency
- Clients and bots report their OpenTelemetry spans (submit → confirm).
Run it locally
Requirements: Rust 1.89, Solana CLI 3.1, Anchor 1.0, Node 24 with pnpm, Docker, Python 3.12.
pnpm install && ./scripts/build-wasm.sh
anchor build --ignore-keys
./scripts/setup-local.sh # base validator + rollup (Docker) + config, model, house, bots
docker run -d --name ringside-pg -e POSTGRES_USER=ringside -e POSTGRES_PASSWORD=ringside \
-e POSTGRES_DB=ringside -p 5434:5432 postgres:16
RINGSIDE_ENV=local cargo +stable run --release --manifest-path services/indexer/Cargo.toml
cd bots && RINGSIDE_ENV=local npx tsx lobby.ts
cd apps/web && pnpm dev # http://localhost:3000Tests: cd tests/magicsvm && cargo +stable test --release runs the program on MagicSVM (rollup, VRF, crank, Magic Actions); ./tests/determinism/run.sh 10000 checks native = WASM = Python. Devnet: ./scripts/devnet-all.sh deploy | services | e2e | eval | soak | report.
Source: github.com/Prashant-thakur77/ringside · MIT licensed.
Glossary
- Tick
- One 100 ms step of the fight; also the unit of price freshness.
- Seen tick
- The tick of the quote a trader acted on, sent with every order.
- Courtsiding
- Trading on an event faster than the price can react.
- Share
- Pays 1.000 test-dollar if its corner wins, nothing otherwise.
- Ephemeral rollup
- A fast execution layer that accounts are delegated to and later committed back to Solana.
- TEE
- Trusted execution environment: the validator that keeps positions private.
- Session key
- A short-lived key your wallet authorises once, so trades need no pop-ups.
- MatchRecord
- The account on Solana holding a match's result and final hash.