Session Lifecycle
Every session goes through these states:| State | Description |
|---|---|
waitingForPlayers | Session created, waiting for players to join (multiplayer) |
pendingStakes | Players have joined, stakes being submitted to blockchain |
escrowConfirmed | Both player and house stakes confirmed on-chain |
inProgress | Game is being played |
pendingSettlement | Game complete, settlement in progress |
settled | Payout complete |
cancelled | Session was cancelled (refunds issued) |
Creating a Session
Parameters
| Parameter | Type | Description |
|---|---|---|
gameDefinitionId | UUID | The game definition from your dashboard |
mode | GameMode | .singlePlayer, .duel, or .tournament |
entryFeeCents | Int | Entry fee in cents (100 = $1.00) |
maxPayoutMultiplier | Double | Maximum possible payout multiplier |
What Happens
When you callstartSession:
- Balance Check - SDK verifies user has sufficient balance
- Session Created - Backend creates session record
- Player Stake Tx - SDK signs and submits player’s stake transaction
- House Stake - Your game admin backend stakes the house side
- Session Ready - Both stakes confirmed, session is
.pendingStakes
Game Modes
Single Player (Blitz)
Player stakes against the house. Payout is determined by the payout table.Duel (Coming Soon)
Two players stake equal amounts. Winner takes the pot (minus platform fee).Tournament (Coming Soon)
Multiple players, prize pool distributed to top finishers. Use case: Leaderboard competitions, bracket tournaments.Payout Tables
Payout tables define how game performance maps to payouts. ZeroSettle supports two types:Discrete Payout Tables
Fixed multipliers for specific outcomes. Perfect for games with countable results. Example: Wordle (solved in N guesses)| Guesses | Multiplier | $1 Stake → Payout |
|---|---|---|
| 1 | 2.0x | $2.00 |
| 2 | 1.8x | $1.80 |
| 3 | 1.5x | $1.50 |
| 4 | 1.2x | $1.20 |
| 5 | 0.8x | $0.80 |
| 6 | 0.5x | $0.50 |
| Failed | 0.0x | $0.00 |
Continuous Payout Tables
Multiplier calculated from a curve function. Perfect for score-based games. Example: 2048 (score-based)Curve Types
| Type | Description | Best For |
|---|---|---|
.linear | Straight line from base to max | Even difficulty scaling |
.exponential(n) | Slow start, fast finish | Rewarding high scores heavily |
.logarithmic | Fast start, slow finish | Rewarding early progress |
Confirming Escrow
AfterstartSession, call confirmEscrow to verify both stakes are on-chain:
- Player stake transaction is confirmed
- House stake transaction is confirmed
- Session is ready for gameplay
Submitting Results
When the game ends, submit the result:What Happens
- Result Submitted - Game result recorded on-chain via your game admin server
- Settlement Triggered - ZeroSettle backend calculates final payout
- On-Chain Settlement - Funds distributed from escrow
- Balance Updated - User’s balance updated via WebSocket
Player Result
Session State
Access the current session via the published property:Session Properties
Error Handling
Session operations can throw these errors:Delegate Callbacks
Implement the delegate for fine-grained control:Best Practices
Always confirm escrow before starting gameplay
Always confirm escrow before starting gameplay
Don’t let users play until
confirmEscrow succeeds. This ensures funds are locked.Handle insufficient balance gracefully
Handle insufficient balance gracefully
Check
balanceCents before showing “Play” button. Disable or show deposit prompt.Use the delegate for UI updates
Use the delegate for UI updates
The delegate gives you real-time updates. Use it to show loading states and confirmations.
Clear session after completion
Clear session after completion
Call
clearActiveSession() when returning to menu to reset state.Test payout calculations locally
Test payout calculations locally
Verify your payout table logic before deploying. Edge cases matter.

