wallet API / Wallet
Undo a bet
/rollbackRefund the bet identified by reference_transaction_id (its full amount, which is also in amount). Sent when SPILVON could not confirm that the bet succeeded, when the game engine failed after the bet, or when a crash bet is cancelled before take-off. Always accept. If you never received that bet, answer TRANSACTION_NOT_FOUND and remember the id so the bet is refused if it arrives late. Refund the stored bet's owner; refuse with TRANSACTION_MISMATCH if player, currency, round or amount differ from the bet, and with ROUND_ALREADY_SETTLED if the round already received its win.
Authentication
X-Spilvon-Operator + X-Spilvon-Timestamp + X-Spilvon-Signature
or X-Spilvon-Operator + X-Spilvon-Timestamp + X-Spilvon-Key-Id + X-Spilvon-Signature-Ed25519 + X-Spilvon-Signature-Ed25519-V2
Request body
operator_idstring · required- The operator the call was signed for: your operator id. Inside the signed bytes (the
X-Spilvon-Operatorheader is not). Refuse the call (401INVALID_SIGNATURE, no money moved) unless it equals your operator id, in HMAC and Ed25519 mode alike: one SPILVON Ed25519 key signs every operator's calls, so this is what stops a call captured by another casino from being replayed at your wallet. Sent on every call since 2026-12 (AUD2-01). player_idstring · required- Your player id, as given at session creation.
currencystring · required- Session currency, fixed for the session.
tokenstring | null · required- Your own session token from session creation, unchanged; null if you did not send one.
session_idstring · requiredgame_codestring · requiredsandboxboolean- Present (true) on every call for a sandbox account, absent otherwise. Play money; a production wallet should refuse such calls.
transaction_idstring · required- Idempotency key of this rollback.
round_idstring · requiredamountallOf · required- Amount of the bet being undone.
reference_transaction_idstring · required- The bet to undo.
round_closedboolean · required
Schema (resolved)
{
"allOf": [
{
"type": "object",
"required": [
"player_id",
"currency",
"token",
"session_id",
"game_code",
"operator_id"
],
"properties": {
"operator_id": {
"type": "string",
"pattern": "^op_[0-9a-f]{32}$",
"description": "The operator the call was signed for: your operator id. Inside the signed bytes (the\n`X-Spilvon-Operator` header is not). **Refuse the call (`401` `INVALID_SIGNATURE`, no money\nmoved) unless it equals your operator id**, in HMAC and Ed25519 mode alike: one SPILVON\nEd25519 key signs every operator's calls, so this is what stops a call captured by another\ncasino from being replayed at your wallet. Sent on every call since 2026-12 (AUD2-01).\n"
},
"player_id": {
"type": "string",
"maxLength": 64,
"pattern": "^[A-Za-z0-9_.@:-]+$",
"description": "Your player id, as given at session creation."
},
"currency": {
"type": "string",
"description": "Session currency, fixed for the session."
},
"token": {
"type": [
"string",
"null"
],
"maxLength": 512,
"description": "Your own session token from session creation, unchanged; null if you did not send one."
},
"session_id": {
"type": "string",
"pattern": "^ses_[0-9a-f]{32}$"
},
"game_code": {
"type": "string",
"pattern": "^[a-z0-9-]{1,32}$"
},
"sandbox": {
"type": "boolean",
"const": true,
"description": "Present (true) on every call for a sandbox account, absent otherwise. Play money; a production wallet should refuse such calls."
}
}
},
{
"type": "object",
"required": [
"transaction_id",
"round_id",
"amount",
"reference_transaction_id",
"round_closed"
],
"properties": {
"transaction_id": {
"type": "string",
"pattern": "^tx_[0-9a-f]{32}$",
"description": "Idempotency key of this rollback."
},
"round_id": {
"type": "string",
"pattern": "^rnd_[0-9a-f]{32}$"
},
"amount": {
"allOf": [
{
"type": "string",
"description": "Decimal string, at most the currency's decimals (2 fiat, 6 USDT/USDC/TRX, 8 BTC/ETH/LTC/SOL/DOGE). SPILVON always sends exactly the currency's decimals.",
"pattern": "^(0|[1-9]\\d{0,17})(\\.\\d{1,8})?$",
"examples": [
"10.00",
"0.00010000"
]
}
],
"description": "Amount of the bet being undone."
},
"reference_transaction_id": {
"type": "string",
"pattern": "^tx_[0-9a-f]{32}$",
"description": "The bet to undo."
},
"round_closed": {
"type": "boolean",
"const": true
}
}
}
]
}{
"player_id": "u-48213",
"currency": "USDT",
"token": "casino-session-7f3a9c",
"session_id": "ses_0193c4d2a1b07e4f9a3c5d6e7f801234",
"game_code": "zenith",
"operator_id": "op_0193c4d2a1b07e4f9a3c5d6e7f801234",
"transaction_id": "tx_0193c4d2a1b07e4f9a3c5d6e7f80ffff",
"round_id": "rnd_0193c4d2a1b07e4f9a3c5d6e7f80abcd",
"amount": "5.000000",
"reference_transaction_id": "tx_0193c4d2a1b07e4f9a3c5d6e7f801111",
"round_closed": true
}Responses
200 Success: {"balance": "<decimal string>"} with the balance **after** the ope
Success: {"balance": "<decimal string>"} with the balance after the operation. Or a definitive refusal / already-done answer: {"error": {"code", "message"}} (HTTP 200 is fine).
Schema (resolved)
{
"oneOf": [
{
"type": "object",
"required": [
"balance"
],
"properties": {
"balance": {
"type": "string",
"description": "Decimal string, at most the currency's decimals (2 fiat, 6 USDT/USDC/TRX, 8 BTC/ETH/LTC/SOL/DOGE). SPILVON always sends exactly the currency's decimals.",
"pattern": "^(0|[1-9]\\d{0,17})(\\.\\d{1,8})?$",
"examples": [
"10.00",
"0.00010000"
]
}
}
},
{
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"required": [
"code"
],
"properties": {
"code": {
"type": "string",
"description": "Recognised codes and their effect:\n\n* Bet refusals (final, no rollback): `INSUFFICIENT_FUNDS`, `LIMIT_REACHED`,\n `PLAYER_BLOCKED`, `TOKEN_INVALID`, `TOKEN_EXPIRED`, `CURRENCY_MISMATCH`,\n `GAME_NOT_ALLOWED`.\n* Already done (win/rollback treated as acknowledged): `DUPLICATE_TRANSACTION`\n (only for an identical repeat); `TRANSACTION_NOT_FOUND` (rollback only).\n* Contract violations you must report this way (read by SPILVON as \"outcome\n unknown\", so they are retried and escalated): `TRANSACTION_MISMATCH` (id reused\n with other details, or a rollback that does not match its bet),\n `ROUND_ALREADY_SETTLED` (rollback after the round's win).\n* Anything else, including `INVALID_SIGNATURE` and `INTERNAL_ERROR`, means\n \"outcome unknown\".\n",
"examples": [
"INSUFFICIENT_FUNDS"
],
"anyOf": [
{
"enum": [
"INSUFFICIENT_FUNDS",
"LIMIT_REACHED",
"PLAYER_BLOCKED",
"TOKEN_INVALID",
"TOKEN_EXPIRED",
"CURRENCY_MISMATCH",
"GAME_NOT_ALLOWED",
"DUPLICATE_TRANSACTION",
"TRANSACTION_NOT_FOUND",
"TRANSACTION_MISMATCH",
"ROUND_ALREADY_SETTLED",
"INVALID_SIGNATURE",
"INTERNAL_ERROR"
]
},
{
"type": "string"
}
]
},
"message": {
"type": "string",
"description": "Optional text for your logs. Not shown to the player."
}
}
}
}
}
]
}Example · success
{
"balance": "987.50"
}Example · insufficient
{
"error": {
"code": "INSUFFICIENT_FUNDS",
"message": "not enough balance"
}
}Example · notFound
{
"error": {
"code": "TRANSACTION_NOT_FOUND",
"message": "no such bet; it will be refused if it arrives"
}
}Example · mismatch
{
"error": {
"code": "TRANSACTION_MISMATCH",
"message": "this transaction_id was already used with different details"
}
}4XX The same error body may be sent with a 4xx status (not 408 or 429, which me
The same error body may be sent with a 4xx status (not 408 or 429, which mean "unknown"). 401 with INVALID_SIGNATURE is the right answer to a request that fails verification (SPILVON treats it as outcome unknown and retries or rolls back).
errorobject · required
Schema (resolved)
{
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"required": [
"code"
],
"properties": {
"code": {
"type": "string",
"description": "Recognised codes and their effect:\n\n* Bet refusals (final, no rollback): `INSUFFICIENT_FUNDS`, `LIMIT_REACHED`,\n `PLAYER_BLOCKED`, `TOKEN_INVALID`, `TOKEN_EXPIRED`, `CURRENCY_MISMATCH`,\n `GAME_NOT_ALLOWED`.\n* Already done (win/rollback treated as acknowledged): `DUPLICATE_TRANSACTION`\n (only for an identical repeat); `TRANSACTION_NOT_FOUND` (rollback only).\n* Contract violations you must report this way (read by SPILVON as \"outcome\n unknown\", so they are retried and escalated): `TRANSACTION_MISMATCH` (id reused\n with other details, or a rollback that does not match its bet),\n `ROUND_ALREADY_SETTLED` (rollback after the round's win).\n* Anything else, including `INVALID_SIGNATURE` and `INTERNAL_ERROR`, means\n \"outcome unknown\".\n",
"examples": [
"INSUFFICIENT_FUNDS"
],
"anyOf": [
{
"enum": [
"INSUFFICIENT_FUNDS",
"LIMIT_REACHED",
"PLAYER_BLOCKED",
"TOKEN_INVALID",
"TOKEN_EXPIRED",
"CURRENCY_MISMATCH",
"GAME_NOT_ALLOWED",
"DUPLICATE_TRANSACTION",
"TRANSACTION_NOT_FOUND",
"TRANSACTION_MISMATCH",
"ROUND_ALREADY_SETTLED",
"INVALID_SIGNATURE",
"INTERNAL_ERROR"
]
},
{
"type": "string"
}
]
},
"message": {
"type": "string",
"description": "Optional text for your logs. Not shown to the player."
}
}
}
}
}{
"error": {
"code": "INVALID_SIGNATURE",
"message": "signature check failed"
}
}Request signing samples
Canonical string and HMAC helpers from the downloadable samples. Wallet callbacks may also use Ed25519; see the wallet signing modes.
Node.js node/spilvon.mjs
export const signingString = (ts, method, pathAndQuery, body) => `${ts}.${method.toUpperCase()}.${pathAndQuery}.${body}`;
export const hmacHex = (secret, s) => createHmac("sha256", secret).update(s, "utf8").digest("hex");Python python/spilvon.py
def signing_string(ts: str, method: str, path_and_query: str, body: str) -> str:
return f"{ts}.{method.upper()}.{path_and_query}.{body}"
def hmac_hex(secret: str, s: str) -> str:
return hmac.new(secret.encode(), s.encode("utf-8"), hashlib.sha256).hexdigest()Go go/main.go
func signingString(ts, method, pathAndQuery, body string) string {
return ts + "." + strings.ToUpper(method) + "." + pathAndQuery + "." + body
}
func hmacHex(secret, s string) string {
m := hmac.New(sha256.New, []byte(secret))
m.Write([]byte(s))
return hex.EncodeToString(m.Sum(nil))
}PHP php/spilvon.php
function signing_string(string $ts, string $method, string $pathAndQuery, string $body): string {
return $ts . '.' . strtoupper($method) . '.' . $pathAndQuery . '.' . $body;
}
function hmac_hex(string $secret, string $s): string {
return hash_hmac('sha256', $s, $secret);
}Reviewed, not executed by the sample authors.