Support for crash games and instant games

Introduction

Crash games and instant games (wheel of fortune, color, instant lotteries) become a key driver of engagement due to the simplicity and speed of the round. Their integration requires a real-time engine that guarantees honesty, low latency and synchrony between hundreds of thousands of players.

1. Real-time round architecture

```mermaid
flowchart LR
subgraph Player
Browser/WebApp
end
subgraph Platform
API-Gateway
AuthService
SessionService
CrashEngine
InstantEngine
MessageBroker[(Kafka)]
end
subgraph RealTime
WS[WebSocket Server]
CR[CrashEngine]
IR[InstantEngine]
end
Browser/WebApp -->WSWS
WS --> SessionService
SessionService --> CrashEngine
SessionService --> InstantEngine
CrashEngine --> MessageBroker
InstantEngine --> MessageBroker
MessageBroker -->eventsWS
WS --> Browser/WebApp
```

CrashEngine: generates growth factors, fixes the moment of "crash."
InstantEngine: starts instant rounds (wheel, lottery), gives the result instantly.
WebSocket Server: broadcasts round events and results, supporting rooms per game.

2. Crash games: logic and calculations

1. Coefficient generation

Using cryptographically strong RNG (libsodium/Chainlink VRF) + HMAC signature.
Growth formula: exponential slope with randomized volatility parameter.
2. Betting moments

At the start of the round, WS sends' {roundId, startTime, crashHash} '.
Players send a'POST/bet' until the'crashTime' moment.
3. Crash and payouts

At the moment of crash, CrashEngine sends' {roundId, crashMultiplier} '.
BetService subtracts the decommissioned rates and multiplies by crashMultiplier.

3. Instant games: Implementing Instant Rounds

1. Wheel of Fortune

InstantEngine generates a'sector'on an equally probable or weighted distribution.
2. ColorPick / DiceRoll

Simple RNG libraries, the result is immediately returned to the API.
3. API call

`POST /instant/{gameType}/play { playerId, stake }` → `{ result, payout }`.

4. API and WebSocket events

REST API

`POST /crash/bet { roundId, playerId, amount }`
`POST /instant/play { gameType, playerId, amount }`
WS events

`crash_start`, `crash_tick { multiplier }`, `crash_end { multiplier }`, `instant_result`.

5. UI/UX and client synchronization

Crash chart

Canvas/WebGL element with growth line animation.
The client timer is synchronized through the server timestamp.
Instant games

The "Play" button instantly blocks the bet and shows the result.
Latency compensation

Ping-pong measurement, delay damping, and visual animation prediction.

6. Safety and integrity

Provably Fair

ServerSeedHash transmission at the start of the round and serverSeed disclosure after the end for verification.
Anti-fraud

Rate limiting by WebSocket and API, DDoS protection.
Atomic transactions

BetService and CrashEngine combine bet recording and payout calculation in one database transaction.

7. Scalability and fault tolerance

Kubernetes

Separate Deployment for CrashEngine and InstantEngine, HPA for QPS/WS sessions.
Kafka

Guaranteed delivery of events rounds and bets.
Redis

Fast keeper of current odds and instant game values.

Conclusion

Support for crash games and instant games requires a real-time engine with minimal latency, provably fair RNG, WebSocket synchronization and a reliable microservice architecture. This integration provides a dynamic and honest gaming experience for high competitive loads.