@octane-rgs/engine
v1.0.8
Published
Maths engine SDK for Octane RGS — settlement, RNG, round data
Readme
@octane-rgs/engine
SDK for maths engines integrating with Octane RGS. Provides settlement, round data management, seed reveal, and re-exports @octane-rgs/rng for local provably fair float generation.
Install
npm install @octane-rgs/engineQuick Start — Instant Games
For instant-resolution games, the maths engine receives seed material from the RGS, generates floats locally, and returns multipliers + gameRoundData. The RGS handles settlement automatically.
import { createFloatGenerator } from "@octane-rgs/engine";
// Inside your maths engine's POST /resolve handler:
function resolve(request) {
const { rng, bets, gameCode } = request;
const { generateFloat } = createFloatGenerator(rng.serverSeed, rng.clientSeed, rng.nonce);
// Game logic (example: Dice)
const float = generateFloat();
const result = Math.floor(float * 10001) / 100;
const won = result > 50;
return {
multipliers: [{ betOption: bets[0].betOption, multiplier: won ? 198 : 0, scale: 100 }],
gameRoundData: { result, won },
};
}For multi-step games (Blackjack, Mines), return gameRoundData + gameState without multipliers on intermediate actions. Return multipliers only when the game resolves.
Quick Start — Live Games
For live games where the external game server controls the round lifecycle:
import { OctaneEngineClient } from "@octane-rgs/engine";
const rgs = new OctaneEngineClient({
baseUrl: "https://your-rgs.example.com",
apiKey: "your-engine-api-key",
});
// Fetch floats from the RGS
const { values } = await rgs.fetchRng({ roundId, count: 6 });
// Update round data with game results
await rgs.updateRoundOutcome(roundId, { grid: [[1, 2, 3]], winLines: [0] });
// Settle the round explicitly
await rgs.settle({
roundId,
gameType: "roulette",
closeRound: true,
multipliers: [{ betOption: "red", multiplier: 2 }],
});API
OctaneEngineClient
| Method | Description |
|--------|-------------|
| settle(params) | Settle a round explicitly (live games) |
| updateRoundOutcome(roundId, data) | Store game outcome data on a round |
| fetchRng(params) | Fetch provably fair random numbers from the RGS (live games) |
| revealSeed(params) | Reveal server seed for verification |
RNG (re-exported from @octane-rgs/rng)
| Function | Description |
|----------|-------------|
| createFloatGenerator(serverSeed, clientSeed, nonce) | Create a stateful generator yielding floats in [0, 1) |
| createFloatGenerator(seed) | Same, accepts a Seed object |
| verify(serverSeed, clientSeed, nonce, count) | Reproduce N floats + server seed hash for verification |
| hashSeed(serverSeed) | SHA-256 hash of a server seed |
Types (re-exported from @octane-rgs/rng)
| Type | Description |
|------|-------------|
| Seed | { serverSeed, clientSeed, nonce } |
| FloatGenerator | { generateFloat(), generateFloats(count) } |
| VerifyResult | { values, serverSeedHash } |
Maths Engine Response Contract
Instant games — the RGS POSTs to your maths engine URL with { roundId, bets, gameCode, gameRoundData, gameState, rng }. Your engine returns:
| Field | Required | Description |
|-------|----------|-------------|
| gameRoundData | Yes | Game outcome data (persisted on the round) |
| multipliers | Optional | Array of { betOption, multiplier, scale? }. When present, the RGS auto-settles |
| gameState | Optional | Player game state for multi-step games |
