The parts
The games element. A custom element,<og-game> unless you rename it, that your page imports from your game server. It draws the games, signs each bet with a key kept in the player’s browser, and shows the Provably fair dialog.
Your session endpoint. Your backend signs a short-lived token for the signed-in player. The game server trusts the token because only your backend and your game server know SESSION_SECRET.
Your game server. One Cloudflare Worker that the dashboard deploys into your Cloudflare account. It serves the element, keeps each player’s bets in its own storage in your account, calls your wallet, and computes every outcome with a VRF key it generated itself. That key never leaves your game server: kinematic holds no key that decides an outcome.
Your wallet. In live mode the game server debits stakes from your wallet and credits payouts to it. Your wallet stays the only place a balance changes. In sandbox mode the game server keeps test balances instead.
The dashboard. It signs your game server’s settings, which the game server fetches about once a minute or at once when you save. It deploys new releases, and it shows the counts, errors and recent bets your game server reports. It never handles a bet.
One bet
- Bet. The browser picks a fresh random seed and keeps it secret. It signs the bet, with the hash of the seed, using the player’s device key, and sends it to your game server.
- Debit. The game server checks the session, your limits and the signature, stores the bet, and debits the stake from your wallet. Bets that arrive together go out in one debit.
- Acceptance. Once the debit applies, the game server signs its acceptance of the bet. The acceptance names the VRF key that will decide it.
- Reveal. Only after the acceptance arrives does the browser send the seed. Until then nobody, including you and kinematic, can know the outcome.
- Outcome. The game server computes the VRF proof over the bet and the seed with your casino’s key, and the game engine turns the VRF output into the result. A win is credited to your wallet as its gross payout.
- Result. The browser receives the result with the seed, the proof and the output, and can recompute the outcome itself.
What survives a failure
- The game server stores each bet before it acknowledges it. A bet resent after a lost connection is recognized by its ID and never placed twice.
- Each wallet call keeps its ID until your wallet answers it. After a timeout or an error the game server sends the same call again, so a stake is never debited twice and a payout is never lost.
- The browser keeps a pending bet’s seed until the bet settles, and sends it again after a reload or a reconnect.
- An accepted bet whose seed never arrives within 24 hours is abandoned, and its stake is refunded.
- Stopping new bets never stops a bet already placed: it still settles and pays.