QUICKSTART
Integrate SPILVON games in a day
This guide is for a casino developer. By the end of it, your players can open SPILVON games in your site, and their bets and wins move money in your wallet. You build two things:
- One signed request that opens a game for a player and returns a URL for an iframe.
- Four wallet endpoints that SPILVON calls:
balance,bet,win,rollback. The money stays with you.
Specifications:
../openapi/operator-api.yaml: what you call.../openapi/wallet-api.yaml: what you implement.
Runnable samples: samples/. The Node, Python and Go samples pass the conformance test; the PHP sample was reviewed but not executed. Postman collection: postman/.
| Time | Step |
|---|---|
| 30 min | 1. Get sandbox credentials and verify the signing recipe against the test vectors |
| 30 min | 2. Launch a demo game (no wallet needed) |
| 3 h | 3. Implement the four wallet endpoints |
| 1 h | 4. Run the conformance test until it is green |
| 1 h | 5. Launch real-money sessions, embed the iframe, wire the Home and Deposit buttons |
| 1 h | 6. Optional: free rounds, revoke, reconciliation |
| — | 7. Go-live checklist |
1. Credentials and signing
What you receive from SPILVON:
- an operator id (
op_+ 32 hex characters); - an API secret, which signs your requests to us;
- a wallet secret, which verifies our requests to you (HMAC mode);
- the sandbox host.
Secrets are shown once. We can rotate them but cannot read them back.
What you give us:
- your wallet base URL (https), e.g.
https://casino.example/spilvon-wallet; - every site origin that will frame the game (
https://casino.example,https://m.casino.example); - optionally, the IP addresses your servers call us from;
- your signing choice for our wallet calls: Ed25519 (recommended), HMAC, or both during a migration.
Sandbox status (30 Nov 2026). The staging environment is configured but not yet deployed. Until it is, use the local system from the repository (
npm run setup:local && npm run dev):
- RGS on
http://localhost:8797- demo casino and reference wallet on
http://localhost:8798Ask your SPILVON contact for a staging account.
The signing recipe (both directions)
X-Spilvon-Operator: <operator id>
X-Spilvon-Timestamp: <unix time in milliseconds, 13 digits>
X-Spilvon-Signature: lowercase_hex( HMAC-SHA256( secret, timestamp + "." + METHOD + "." + path_and_query + "." + raw_body ) )- Sign the exact bytes you send, and send exactly the string you signed. For
GETthe body is the empty string. path_and_queryis the path plus query string, without the host:/api/v1/operator/reports/daily?from=2026-12-01&to=2026-12-31.- Timestamps more than 300 s off are rejected. Keep NTP running.
- Each signature is accepted once. To retry, sign again.
- When verifying our calls: verify before parsing JSON, compare in constant time, and check
X-Spilvon-Operatorequals your id.
Check your implementation against the test vectors first (docs/signature-test-vectors.json). The vector below is one of them:
secret test-secret-do-not-use-0123456789abcdef
string 1767225602000.GET./api/v1/operator/reports/daily?from=2026-12-01&to=2026-12-31.
signature 5a3530ab26f5db2a6fb06c4fba8981a57fe29aa3841d628deab0be676502d4c1Ed25519 (recommended for our calls to your wallet)
With Ed25519 you hold no secret that could forge our calls. You verify with our public key.
- Every call carries
X-Spilvon-Key-IdandX-Spilvon-Signature-Ed25519: standard base64 of the 64-byte signature over the same signing string. - Fetch the keys from
GET https://<spilvon-host>/.well-known/spilvon-wallet-keys.jsonand cache them. Refetch daily, and once when you see an unknownkid; then reject. - Keys have a status:
activesigns,nextis published ahead of a rotation,retiredno longer signs. - Test key: the RFC 8032 key in
signature-test-vectors.json→ed25519. It is public; never trust it in production.
Your requests to SPILVON are always HMAC with your API secret.
2. Launch a demo game (5 minutes)
Demo mode uses play money held by SPILVON and needs no wallet:
# Node 18+, with SPILVON_URL, SPILVON_OPERATOR and SPILVON_API_SECRET set
node -e '
const c = require("node:crypto");
const path = "/api/v1/operator/sessions";
const body = JSON.stringify({ currency: "USD", game_code: "dice", mode: "demo", lang: "en" });
const ts = String(Date.now());
const sig = c.createHmac("sha256", process.env.SPILVON_API_SECRET).update(`${ts}.POST.${path}.${body}`).digest("hex");
fetch(process.env.SPILVON_URL + path, { method: "POST", body, headers: { "content-type": "application/json",
"x-spilvon-operator": process.env.SPILVON_OPERATOR, "x-spilvon-timestamp": ts, "x-spilvon-signature": sig } })
.then(r => r.json()).then(console.log);'Open the returned launch_url in a browser within 120 seconds. Each URL works once.
The game list comes from GET /api/v1/operator/games. Launch only games where enabled and client_ready are true.
With Postman instead:
- Import
postman/spilvon-operator-api.postman_collection.jsonandpostman/spilvon-local.postman_environment.json. - Fill in
operatorIdandapiSecret. - Send Sessions → Create session (demo).
The collection signs every request in its pre-request script. The Postman console shows the signing string, which helps when debugging a mismatch.
3. Implement the wallet
SPILVON calls POST {wallet_url}/balance, /bet, /win and /rollback.
Every call carries:
player_idcurrencytoken: your own session token, echoed backsession_idgame_code
Money calls also carry:
transaction_idround_idamount: a decimal string, never a numberround_closed
win and rollback also carry reference_transaction_id, the bet they belong to.
| Call | You do | Answer |
|---|---|---|
balance | read the balance | {"balance":"987.50"} |
bet | check that token is a live session of this player (else TOKEN_INVALID), then debit all or nothing, or refuse | {"balance":…} or {"error":{"code":"INSUFFICIENT_FUNDS"}} |
win | credit (may be "0.00": that closes a lost round). Always accept, even after logout | {"balance":…} |
rollback | refund the referenced bet once, to the bet's owner. If you never saw it, answer TRANSACTION_NOT_FOUND and remember that bet id, so the bet is refused if it arrives late. Refuse with TRANSACTION_MISMATCH if it does not match the bet (player, currency, round, amount), and with ROUND_ALREADY_SETTLED if the round already got its win | {"balance":…} or {"error":{"code":"TRANSACTION_NOT_FOUND"}} |
Bet refusals (final; no rollback follows):
INSUFFICIENT_FUNDSLIMIT_REACHEDPLAYER_BLOCKEDTOKEN_INVALIDTOKEN_EXPIREDCURRENCY_MISMATCHGAME_NOT_ALLOWED
Already done (for a win or rollback you processed before): DUPLICATE_TRANSACTION, or simply return the same success body again.
Anything else is "outcome unknown". That includes a timeout (6 s), a 5xx, a redirect, a non-JSON body, or an unknown code. SPILVON then:
- for a bet: cancels it and sends a rollback. Bets are never retried.
- for a win or rollback: retries with the same
transaction_idafter 2 s, 5 s, 15 s, 1 min, 5 min, 15 min, then hourly, until you acknowledge.
Rules that make a wallet correct:
- Idempotency. Store
transaction_idwith a UNIQUE constraint, together with its details. An identical repeat changes nothing and gets the same answer. The same id with different details (amount, player, currency, round, reference) is not a retry: refuse it withTRANSACTION_MISMATCH. Never answerDUPLICATE_TRANSACTIONthere, because we read that as "already done". - One database transaction per call, covering the balance update and the transaction row.
- A second rollback of the same bet, under a new id, refunds nothing. A rollback never refunds a different player than the one who placed the bet.
- Check
tokenon bets only. Wins and rollbacks are accepted without a live session. - Free-round wins arrive as
winwithfree_round: trueandreference_transaction_id: null. No bet preceded them. Credit them like any win. - Ignore fields you do not recognise. We add optional fields over time.
- Answer in under 500 ms.
Node.js (from samples/node/spilvon.mjs)
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifySpilvon(headers, method, pathAndQuery, rawBody) {
const ts = headers["x-spilvon-timestamp"] ?? "";
if (headers["x-spilvon-operator"] !== process.env.SPILVON_OPERATOR || !/^\d{13}$/.test(ts) || Math.abs(Date.now() - Number(ts)) > 300_000) return false;
const expected = Buffer.from(createHmac("sha256", process.env.SPILVON_WALLET_SECRET).update(`${ts}.${method}.${pathAndQuery}.${rawBody}`, "utf8").digest("hex"));
const given = Buffer.from(String(headers["x-spilvon-signature"] ?? ""));
return given.length === expected.length && timingSafeEqual(given, expected);
}
// inside one DB transaction per call:
export function handle(method, b) {
if (method === "balance") return ok();
const amount = toMinor(b.amount, decimals(b.currency)); // integers, never floats
const seen = txs.get(b.transaction_id);
if (seen) return sameDetails(seen, method, b, amount) ? ok() // 1. idempotent
: { error: { code: "TRANSACTION_MISMATCH" } }; // same id, other details
if (method === "bet") {
if (tombstones.has(b.transaction_id)) return { error: { code: "TRANSACTION_NOT_FOUND" } };
if (sessions.get(b.token) !== b.player_id) return { error: { code: "TOKEN_INVALID" } };
if (balance < amount) return { error: { code: "INSUFFICIENT_FUNDS" } };
balance -= amount;
} else if (method === "win") {
balance += amount; // always accepted
} else if (method === "rollback") {
const bet = txs.get(b.reference_transaction_id);
if (!bet) { tombstones.add(b.reference_transaction_id); return { error: { code: "TRANSACTION_NOT_FOUND" } }; }
if (!matchesBet(bet, b, amount)) return { error: { code: "TRANSACTION_MISMATCH" } };
if (roundWon(bet)) return { error: { code: "ROUND_ALREADY_SETTLED" } };
if (!bet.rolledBack) { credit(bet.player, bet.amount); bet.rolledBack = true; }
}
txs.set(b.transaction_id, { type: method, amount });
return ok();
}The full file also contains the HTTP server, Ed25519 verification with crypto.verify, and launch. Run it with node spilvon.mjs wallet.
Python (from samples/python/spilvon.py)
import hmac, hashlib, time
def verify_spilvon(headers, method, path_and_query, raw_body):
ts = headers.get("X-Spilvon-Timestamp", "")
if headers.get("X-Spilvon-Operator") != OPERATOR or not (ts.isdigit() and len(ts) == 13):
return False
if abs(time.time() * 1000 - int(ts)) > 300_000:
return False
s = f"{ts}.{method}.{path_and_query}.{raw_body}"
expected = hmac.new(WALLET_SECRET.encode(), s.encode("utf-8"), hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, headers.get("X-Spilvon-Signature", ""))
# Ed25519 (pip install cryptography):
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
Ed25519PublicKey.from_public_bytes(base64.b64decode(public_key_b64)).verify(base64.b64decode(sig_b64), s.encode())Run it with python3 spilvon.py wallet. Standard library only, apart from cryptography for Ed25519.
PHP (from samples/php/spilvon.php; reviewed, not executed)
function verify_spilvon(string $method, string $pathAndQuery, string $rawBody): bool {
$ts = $_SERVER['HTTP_X_SPILVON_TIMESTAMP'] ?? '';
if (($_SERVER['HTTP_X_SPILVON_OPERATOR'] ?? '') !== getenv('SPILVON_OPERATOR') || !preg_match('/^\d{13}$/', $ts)) return false;
if (abs((int) floor(microtime(true) * 1000) - (int) $ts) > 300000) return false;
$s = "$ts.$method.$pathAndQuery.$rawBody";
return hash_equals(hash_hmac('sha256', $s, getenv('SPILVON_WALLET_SECRET')), $_SERVER['HTTP_X_SPILVON_SIGNATURE'] ?? '');
}
$raw = file_get_contents('php://input'); // verify these bytes BEFORE json_decode
// Ed25519: sodium_crypto_sign_verify_detached(base64_decode($sig), $s, base64_decode($publicKey))The sample keeps state in SQLite with one transaction per call and does amounts with bcmath.
Go (from samples/go/main.go)
func verifySpilvon(h http.Header, method, pathAndQuery, rawBody string) bool {
ts := h.Get("X-Spilvon-Timestamp")
if h.Get("X-Spilvon-Operator") != os.Getenv("SPILVON_OPERATOR") || !tsRe.MatchString(ts) {
return false
}
t, _ := strconv.ParseInt(ts, 10, 64)
if d := time.Now().UnixMilli() - t; d > 300_000 || d < -300_000 {
return false
}
s := ts + "." + method + "." + pathAndQuery + "." + rawBody
if sig := h.Get("X-Spilvon-Signature-Ed25519"); sig != "" && len(edKeys) > 0 {
key, ok := edKeys[h.Get("X-Spilvon-Key-Id")]
raw, err := base64.StdEncoding.DecodeString(sig)
return ok && err == nil && ed25519.Verify(key, []byte(s), raw)
}
m := hmac.New(sha256.New, []byte(os.Getenv("SPILVON_WALLET_SECRET")))
m.Write([]byte(s))
return hmac.Equal([]byte(hex.EncodeToString(m.Sum(nil))), []byte(h.Get("X-Spilvon-Signature")))
}Run it with go run . wallet. Standard library only.
4. Run the conformance test
The conformance test plays the part of our game server. It sends the exact signed calls we send in production to your wallet, including the awkward ones:
- repeats;
- a forged signature;
- a stale timestamp;
- a rollback that arrives before its bet;
- a free-round win and a separate jackpot credit (
kind: "jackpot"), neither requiring a prior bet.
It leaves the test player's balance where it started.
# HMAC. --token must be a LIVE casino session token of the test player (a made-up one must be refused)
node tools/wallet-conformance.ts --url https://casino.example/spilvon-wallet \
--operator op_xxx --secret <wallet secret> --player <test player with ≥ 10 units> \
--token <live session token> --currency USD
# Ed25519: your wallet must trust the public RFC 8032 test key (kid "test-rfc8032-1") for the run
node tools/wallet-conformance.ts --signing ed25519 --url https://casino.example/spilvon-wallet \
--operator op_xxx --player <test player> --token <live session token> --currency USDTExit code 0 means every check passed (Ed25519 mode also checks an unknown signing key id). The tool also reads the balance of a second player, <player>-conf-other, to prove a rollback cannot credit the wrong account. The tool currently ships inside the SPILVON repository and needs Node 22.18 or newer. Ask your SPILVON contact for the standalone file until it is published on the developer portal.
The Node, Python and Go samples were checked with this tool on 2026-11-30 in both signing modes, and all checks passed. To run them, set SPILVON_SAMPLE_TOKENS='{"<token>":"<player>"}'; that stands in for your session store.
To exercise the wallet by hand, use the Wallet simulator folder of the Postman collection:
- Set
walletUrlandwalletSecret. - Run Prepare ids.
- Send
bet, thenwin(send each twice), thenrollback.
5. Real-money launch and the iframe
POST /api/v1/operator/sessions
Content-Type: application/json
X-Spilvon-Operator: op_…
X-Spilvon-Timestamp: 1767225601234
X-Spilvon-Signature: …
{"player_id":"u-48213","currency":"USDT","game_code":"zenith","token":"<your session token>",
"lang":"en","country":"DE","device":"mobile",
"lobby_url":"https://casino.example/lobby","deposit_url":"https://casino.example/cashier"}The response is 201: {"session_id":"ses_…","player_id":"u-48213","launch_url":"https://…/play/zenith?t=…","expires_in":120}
<iframe src="LAUNCH_URL" allow="autoplay; fullscreen" style="border:0;width:100%;height:100%"></iframe>- Create a new session for every launch. The URL works once, within 120 s.
- Only your registered origins can frame the game. On phones, give the frame the whole viewport.
- Jurisdiction rules. If your account holds several licences, send
"jurisdiction"with the profile code (published so far:default,uk,de). SPILVON then applies that profile: feature buys, autoplay limits, minimum cycle time, session clock, reality check, stake caps. Some profiles require more fields: player_age_band(18-24or25+);history_url.
Optional fields: reality_check_minutes (may only tighten the profile) and session_started_at (your login time, in epoch ms). Ask your SPILVON contact which profiles your account holds.
tokenis your own session token. It comes back on every wallet call, so you can find the session; use it to refuse bets after logout (TOKEN_EXPIRED).
Messages from the game to your page (check event.origin):
window.addEventListener("message", (e) => {
if (e.origin !== "https://<spilvon-host>" || e.data?.source !== "spilvon") return;
switch (e.data.type) {
case "deposit": openCashier(); break; // player pressed Deposit
case "exit": location.href = "/lobby"; break; // player pressed Home
case "roundEnd": /* e.data.round_id, bet, payout */ break;
case "balance": /* e.data.balance, currency */ break;
}
});
// after a deposit:
frame.contentWindow.postMessage({ source: "spilvon-host", type: "refreshBalance" }, "https://<spilvon-host>");
// also: pause, resume, mute, unmute, stopAutoplayErrors from our API have the shape {"error":{"code":"…","message":"…"},"request_id":"…"}. Branch on code, and quote request_id to support. Common codes:
| Code | Meaning |
|---|---|
INVALID_SIGNATURE | Wrong secret, wrong signing string, or upper-case hex |
TIMESTAMP_OUT_OF_RANGE | Check your clock |
REPLAYED_REQUEST | You resent the same signed request; sign again |
GAME_DISABLED | The game is not enabled for you |
CURRENCY_NOT_SUPPORTED | The currency is not available for you |
RATE_LIMITED | Honour Retry-After |
6. Optional on day one
Revoke a player's sessions (logout, self-exclusion): POST /api/v1/operator/players/{player_id}/revoke, empty body. Open rounds still settle.
Free rounds:
POST /api/v1/operator/free-rounds
{"reference":"welcome-u48213","player_id":"u-48213","currency":"USD",
"game_codes":["thunder-anvil"],"rounds":20,"stake":"0.20","valid_until":"2026-12-31T23:59:59Z"}- Idempotent per
referenceand player. - The player sees the award at their next launch of an eligible game.
- Each round's win reaches your wallet as a flagged
win. - Other calls: list (
GET /api/v1/operator/free-rounds?reference=…), get, and cancel (one award, or all awards of a reference).
Reconciliation: GET /api/v1/operator/reports/daily?from=YYYY-MM-DD&to=YYYY-MM-DD gives rounds, bets, wins, GGR, free-round totals and net_ggr per UTC day, game and currency. Compare it with your ledger daily.
Support: GET /api/v1/operator/rounds/{round_id} returns the result, fairness data and every transaction of a finished round.
7. Go-live checklist
Signing
- Your signing passes every vector in
signature-test-vectors.json: HMAC, plus Ed25519 if you chose it. - With Ed25519, an unknown key id triggers one key refetch and then a rejection.
Wallet correctness
- The conformance test passes against your staging wallet. Rerun it after any change of wallet URL, signing mode or deployment.
betwith insufficient balance returnsINSUFFICIENT_FUNDSand debits nothing.- The same
winsent three times credits once. - A
rollbackof an unknown bet returnsTRANSACTION_NOT_FOUND, and that bet is refused if it arrives later. winandrollbacksucceed for a player whose session has ended or who is blocked.- A
betwith an unknown token, or another player's token, is refused (TOKEN_INVALID). - A reused
transaction_idwith different details is refused (TRANSACTION_MISMATCH). A rollback after the round's win is refused (ROUND_ALREADY_SETTLED). - Your wallet ignores unknown fields in our calls.
Performance and monitoring
- Wallet p95 is under 500 ms at your peak. Alert when p99 exceeds 2 s or the 5xx rate exceeds 1%.
Launch and front end
- Every site origin that frames the game is registered. The game loads in your frame on desktop, phone and tablet.
- The Home and Deposit buttons work (
lobby_url,deposit_url, or theexit/depositmessages). - Logout and self-exclusion call
revoke.
Reconciliation
- For a test day, your totals match
reports/daily. - After go-live, watch the first 100 real-money rounds and reconcile them one by one with
GET /rounds/{id}.
Support
- Your support team knows to quote
request_idandround_id.