API Reference
Reference

Every postMessage type, parameter, and response field in one place. All messages use id-based request/response matching.

Global Messages (All Primitives)

gameReady

Send once when your game loads. Required — the platform won't send data until it receives this.

FieldTypeDescription
type'gameReady'Message type
1parent.postMessage({ type: 'gameReady' }, '*');

balanceReveal

Optional — supported by all primitives. Post this when you want the player's balance to visually update — typically at the dramatic reveal moment (e.g. when a ball lands, a card flips, a winner is shown, or a cashout animation completes).

The platform always settles the bet in the backend immediately when the API responds. This message only controls when the player sees the new balance. If you never send it, the balance updates automatically after 30 seconds as a fallback.

The deferred moment differs by primitive:

PrimitiveRecommended reveal moment
one-shotWhen the outcome animation completes (ball lands, wheel stops, card flips)
pathWhen the cashout payout animation completes (pathCashout or auto-cashout via pathReveal)
multiplierWhen the cashout celebration animation completes (multiplierCashout)
state-machineWhen the terminal-state outcome animation completes (final stateMachineAction with gameOver)
pvpWhen the winner reveal animation completes (pvpResult / pvpCancelled / pvpResolve)
FieldTypeDescription
type'balanceReveal'Message type
1// In your animation callback, when the outcome is revealed:
2parent.postMessage({ type: 'balanceReveal' }, '*');

For multi-ball or concurrent bets, send one balanceReveal per outcome — the platform processes them in FIFO order (first bet placed = first balance update applied).

stakeUpdate (incoming)

Platform pushes this when the player changes their bet amount in the UI.

FieldTypeDescription
type'stakeUpdate'Message type
stakenumberNew bet amount in crypto
stakeUsdnumberNew bet amount in USD
currencystring'ETH' | 'SOL' | 'USDT'

sessionResume (incoming)

Platform sends this on load if there's an active session for a stateful primitive (path, multiplier, state-machine).

FieldTypeDescription
type'sessionResume'Message type
primitivestring'path' | 'multiplier' | 'state-machine'
sessionobjectSession data (sessionId, currentState, etc.)

Error Codes

These errors can appear in any response. Check r.error (one-shot) or d.error (other primitives) before processing results.

Error StringCause
'Insufficient balance'Player can't cover the bet
'Rate limited'Messages sent faster than 1 per 25ms
'Invalid stake'Stake is zero, negative, or NaN
'Invalid currency'Currency not recognized
'Game not found'GAME_CONFIG missing or game not uploaded
'Session expired'Game session timed out (long inactivity)
'Session not found'Invalid or already-ended sessionId
'Invalid action'Action not in allowedActions (state machine)
'Invalid position'Position out of range (path)
'Match not found'Invalid matchId (PVP)
'Already committed'Player already committed an action (PVP)
'Round crashed - too late!'Cashout after crash point (multiplier)

One Shot

bet → betResult

bet (outgoing)

FieldTypeRequiredDescription
type'bet'YesMessage type
idnumberYesUnique request ID (use Date.now())
stakenumberYeswindow.GAME_STAKE
currencystringYeswindow.GAME_CURRENCY
targetMultipliernumberContinuous onlyPlayer's chosen target (continuous mode)
variantstringVariants onlySelects which multiplier set to use (for games with multiple configurations)

betResult (incoming)

Matched by id. Result fields are inside e.data.result.

FieldTypeDescription
result.multipliernumberWinning multiplier (e.g. 5)
result.resultstring'WIN' | 'LOSS' | 'PUSH'
result.payoutnumberCrypto payout
result.payoutUsdnumberUSD payout
result.profitnumberCrypto profit (can be negative)
result.profitUsdnumberUSD profit
result.balancenumberNew balance after bet
result.errorstring?Error string if bet failed

Path

pathStart → (get sessionId) → pathReveal × N → pathCashout (or hit hazard)

pathStart (outgoing)

FieldTypeRequiredDescription
type'pathStart'YesMessage type
idnumberYesUnique request ID
stakenumberYeswindow.GAME_STAKE
currencystringYeswindow.GAME_CURRENCY

pathStart response

FieldTypeDescription
sessionIdstringUse for subsequent reveal/cashout
positionHashstringProvably fair commitment hash
gridSizenumberTotal positions
minesnumberNumber of hazards
maxStepsnumberMax safe picks allowed
replacementbooleanReplacement mode
multipliersarrayFull payout table [{step, multiplier, survivalProb}]
stake / stakeUsd / currencynumber / stringBet details

pathReveal (outgoing)

FieldTypeRequiredDescription
type'pathReveal'YesMessage type
idnumberYesUnique request ID
sessionIdstringYesFrom pathStart response
positionnumberYes0-indexed tile position

pathReveal response (safe)

FieldTypeDescription
survivedtruePlayer is safe
stepnumberCurrent step number
multipliernumberCurrent multiplier
potentialPayout / potentialPayoutUsdnumberWhat cashout would pay
nextMultipliernumberNext step's multiplier
nextSurvivalProbnumberChance of surviving next step
revealedTilesnumber[]All safe tiles revealed so far
canCashout / canContinuebooleanAvailable actions
gameOverfalseGame continues

pathReveal response (hazard)

FieldTypeDescription
survivedfalsePlayer hit a mine
hitMinetrueConfirms hazard hit
multiplier0Zero payout
payout0Zero payout
minePositionsnumber[] | number[][]Flat (no replacement) or 2D (replacement)
serverSeedstringFor verification
gameOvertrueGame ended

pathCashout (outgoing)

FieldTypeRequiredDescription
type'pathCashout'YesMessage type
idnumberYesUnique request ID
sessionIdstringYesFrom pathStart response

pathCashout response

FieldTypeDescription
successtrueCashout succeeded
step / multipliernumberFinal step and multiplier
payout / payoutUsdnumberCrypto and USD payout
profit / profitUsdnumberCrypto and USD profit
minePositionsnumber[] | number[][]Revealed mine positions
serverSeedstringFor verification
gameOvertrueGame ended

Multiplier

multiplierStart → (animate locally) → multiplierCashout or serverCrash

multiplierStart (outgoing)

FieldTypeRequiredDescription
type'multiplierStart'YesMessage type
idnumberYesUnique request ID
stakenumberYeswindow.GAME_STAKE
currencystringYeswindow.GAME_CURRENCY

multiplierStart response

FieldTypeDescription
sessionIdstringUse for cashout
commitHashstringProvably fair commitment
serverSeedHashstringHash of server seed
curvestring'exponential' | 'linear'
growthRatenumberGrowth speed
maxMultipliernumberCap
startTimenumberServer timestamp (ms)
stake / stakeUsdnumberBet details

multiplierCashout (outgoing)

FieldTypeRequiredDescription
type'multiplierCashout'YesMessage type
idnumberYesUnique request ID
sessionIdstringYesFrom multiplierStart response

multiplierCashout response (success)

FieldTypeDescription
successtrueCashed out before crash
multipliernumberCashout multiplier
payout / payoutUsdnumberCrypto and USD payout
profit / profitUsdnumberCrypto and USD profit
crashPointnumberThe actual crash point (revealed)
serverSeed / commitHashstringFor verification
gameOvertrueRound ended

multiplierCashout response (too late)

FieldTypeDescription
errorstring'Round crashed - too late!'
crashedtrueRound already crashed
crashPointnumberThe crash point
payout / payoutUsd0No payout
serverSeed / commitHashstringFor verification
gameOvertrueRound ended

serverSync (push event)

FieldTypeDescription
type'serverSync'Message type
serverNowMsnumberServer's current timestamp (ms)

serverCrash (push event)

FieldTypeDescription
type'serverCrash'Message type
crashMultipliernumberThe crash point
serverSeed / commitHashstringFor verification

PVP Escrow

pvpCreate → (wait for opponent) → pvpCommit → (wait for resolve) → pvpResult

pvpCreate (outgoing)

FieldTypeRequiredDescription
type'pvpCreate'YesMessage type
idnumberYesUnique request ID
stakenumberYeswindow.GAME_STAKE
currencystringYeswindow.GAME_CURRENCY
resolverstringYesMust match GAME_CONFIG resolver

pvpCreate response

FieldTypeDescription
matchIdstringUse for commit/cancel
statusstring'waiting' or 'ready'
potnumberTotal pot amount
feenumberHouse fee rate
matchedbooleantrue if opponent found immediately
opponentUsernamestring?Present if matched
playersarray[{id, stakeUsd}] — your ID is last
stakeUsdnumberYour stake in USD
resolverstringResolver type

pvpCommit (outgoing)

FieldTypeRequiredDescription
type'pvpCommit'YesMessage type
idnumberYesUnique request ID
matchIdstringYesFrom pvpCreate response
actionstringYese.g. 'rock', 'heads', or a number

pvpCommit response

FieldTypeDescription
successtrueAction committed
committedtrueConfirms commitment

pvpCancel (outgoing)

FieldTypeRequiredDescription
type'pvpCancel'YesMessage type
idnumberYesUnique request ID
matchIdstringYesFrom pvpCreate response

pvpCancel response

FieldTypeDescription
successtrueMatch cancelled, funds returned

pvpOpponentJoined (push event)

FieldTypeDescription
type'pvpOpponentJoined'Message type
matchIdstringMatch ID
opponentUsernamestringOpponent's username
potnumberTotal pot
status'ready'Match is ready for commits

pvpOpponentCommitted (push event)

FieldTypeDescription
type'pvpOpponentCommitted'Message type
matchIdstringMatch ID
playerIdstringWho committed
allCommittedbooleantrue if both players committed
status'playing'Match status

pvpResult (push event)

FieldTypeDescription
type'pvpResult'Message type
matchIdstringMatch ID
status'resolved'Match resolved
outcomestring'player1_wins' | 'player2_wins' | 'draw'
winnerstring?Winner's player ID (null for draw)
potnumberTotal pot
houseFeenumberFee taken
prizePoolnumberPot minus fee
payoutsarray[{playerId, amount}]
playersarray[{id, action}] — reveals both actions
serverSeedstringFor verification

pvpCancelled (push event)

FieldTypeDescription
type'pvpCancelled'Message type
matchIdstringMatch ID
status'cancelled'Match was cancelled

State Machine

stateMachineStart → (get sessionId + state) → stateMachineAction × N → terminal state

stateMachineStart (outgoing)

FieldTypeRequiredDescription
type'stateMachineStart'YesMessage type
idnumberYesUnique request ID
stakenumberYeswindow.GAME_STAKE
currencystringYeswindow.GAME_CURRENCY

stateMachineStart response

FieldTypeDescription
sessionIdstringUse for subsequent actions
currentState[string, any]Current state [key, data]
allowedActionsstring[]Available actions
totalWagernumberTotal wagered so far
status'playing'Session status
commitHashstringProvably fair commitment
stake / stakeUsdnumberBet details

stateMachineAction (outgoing)

FieldTypeRequiredDescription
type'stateMachineAction'YesMessage type
idnumberYesUnique request ID
sessionIdstringYesFrom start response
actionstringYesMust be in allowedActions

stateMachineAction response (non-terminal)

FieldTypeDescription
currentState[string, any]New state
allowedActionsstring[]Next available actions
totalWagernumberTotal wagered
totalPayout0No payout yet
gameOverfalseGame continues
status'playing'Session status

stateMachineAction response (terminal)

FieldTypeDescription
currentState[string, any]Final state
allowedActions[]No actions (game over)
totalWagernumberTotal wagered
totalPayoutnumberFinal payout multiplier
payoutMultipliernumberSame as totalPayout
payoutUsdnumberUSD payout amount
serverSeedstringFor verification
gameOvertrueGame ended
status'finished'Session status
Bookmark this page — it covers every message type across all five primitives. For detailed explanations and complete templates, see each primitive's dedicated page.