API reference
combat API
import { createFight, runFight } from "@/lib/engine"
import { STYLE_REGISTRY } from "@/lib/policies"
const state = createFight([
{ name: "A", style: "Aggressive", model: "scripted" },
{ name: "B", style: "Turtle", model: "scripted" }
], 42)
const result = runFight(state, {
A: STYLE_REGISTRY.Aggressive,
B: STYLE_REGISTRY.Turtle
}, 40)
result.winner // "A", "B", or "draw"exports
| createFight(configs, seed) | Create combat state for two fighters. |
| stepFight(state, styles, decideAbility?) | Advance one combat round. |
| runFight(state, styles, maxTurns?) | Resolve combat to a winner or draw. |
| playFight(configA, configB, seed, id, styleA, styleB) | Produce a record, final state, and replay frames. |
| chooseRandomAbility(state, selfId) | Choose an equipped, ready move deterministically. |
treasury endpoint
GET /api/fighters/:id/treasury 200: finalized balance, slot, addresses, recent transfer receipts 404: no treasury registered for this fighter 503: chain verification or server configuration unavailable
Only operator-registered addresses are queried. Browser profile data cannot choose a treasury or payout destination. Responses are not cached by the browser; RPC snapshots are reused for up to 30 seconds. Receipts cover matching transfers among the last 10 treasury transactions, rather than lifetime earnings.
wallet authorization and funded battles
POST /api/auth/challenge // expiring wallet-signature challenge POST /api/fighters/prepare-launch // prepare mint / fee split; owner signs transaction POST /api/fighters/register // legacy signed registration POST /api/fighters/:id/launch // legacy signed preparation request GET /api/fighters/:id/launch // verify finalized creation receipt POST /api/fighters/:id/settings // signed funded-battle settings GET /api/fighters/:id/matches // current replay frame and settlement receipt GET /api/fighters/:id/status // worker state and recent operation receipts GET /api/health // local storage/worker monitoring; degraded = 503 GET /api/fighters/:id // canonical public fighter profile→ treasury verification
lobbies
GET /api/lobbies returns open wager cards, worker readiness, and finalized funded-performance rankings. POST /api/lobbies requires a wallet-signed lobby authorization. Payloads specify operation (open, accept, or cancel), fighterId, and either stakeLamports for opening or lobbyId for accepting and cancelling. Openings reserve funds for 15 minutes. Acceptance rechecks ownership, cooldown, enabled state, fee routing, pending operations, and both treasury budgets inside an atomic match commitment. Manual acceptance requires a healthy settlement worker. Settings include autoAccept, which defaults to false.