Integration Docs
Everything you need to embed Solex games into your casino platform — Prediction Markets and TraderHero.
Interactive REST API reference.
Live Prediction Markets demo.
Live TraderHero jackpot demo.
Deposit, win, and refund webhooks.
Two Integration Modes
Both games support two modes of operation. The mode is determined by whether you pass a JWT token to the iframe.
- • No JWT token passed
- • Simulated balance managed by the host page
- • No webhooks fired — balance changes via postMessage only
- • Great for previews and try-before-you-buy
- • Host passes JWT token to iframe
- • Backend verifies JWT against partner config
- • Real balance managed server-side via webhooks
- • All transactions tracked with unique IDs
Prediction Markets — Iframe Setup
Prediction Markets are embedded via an iframe. The host page communicates with the iframe using the postMessage API through our SDK.
<iframe id="solex-frame"
src="https://solex-integration-demo-production.up.railway.app/embed/embed/markets"
style="width:100%;aspect-ratio:16/9;border:none;">
</iframe>
<script src="/solex-casino-sdk.js"></script>
<script>
const sdk = new SolexCasinoSDK(
document.getElementById('solex-frame'),
{
casinoId: 'your-partner-uuid',
apiKey: 'sk_your_api_key',
user: { id: 'player_123', displayName: 'Player' },
balance: { available: 1500, reserved: 0,
currency: 'USD', currencySymbol: '$' },
}
);
sdk.initialize();
</script>TraderHero — Iframe Setup
TraderHero uses a simpler postMessage protocol (no SDK wrapper needed). The host page communicates directly with jackpot_* messages.
<iframe id="traderhero-frame"
src="https://solex-integration-demo-production.up.railway.app/jackpot/"
style="width:100%;aspect-ratio:4/3;border:none;">
</iframe>
<script>
const iframe = document.getElementById('traderhero-frame');
// Send initial balance when iframe loads
iframe.onload = () => {
iframe.contentWindow.postMessage(
{ type: 'jackpot_balance_response', balance: 1500 },
'*'
);
};
// Listen for iframe messages
window.addEventListener('message', (e) => {
const { type, amount } = e.data;
if (type === 'jackpot_balance_deduct') {
// Player bet — deduct balance, confirm
balance -= amount;
iframe.contentWindow.postMessage(
{ type: 'jackpot_balance_response', balance },
'*'
);
}
if (type === 'jackpot_balance_credit') {
// Player won — credit balance, confirm
balance += amount;
iframe.contentWindow.postMessage(
{ type: 'jackpot_balance_response', balance },
'*'
);
}
});
</script>TraderHero backend endpoints (POST /jackpot/rounds, POST /jackpot/rounds/:id/settle) require the X-Casino-Key header. The iframe calls these directly — ensure your API key is configured.
Prediction Markets — SDK Messages
| Message | Direction | Description |
|---|---|---|
| CASINO_INIT | Host → Iframe | Initialize session with user, balance, theme, currency |
| CASINO_BALANCE_UPDATE | Host → Iframe | Update player balance (after webhook confirmation) |
| CASINO_THEME_UPDATE | Host → Iframe | Change CSS variables for white-label theming |
| CASINO_BANNER_UPDATE | Host → Iframe | Set image or HTML banner at 3 positions |
| CASINO_AD_SLOTS_UPDATE | Host → Iframe | Inject inline ad cards into the feed |
| CASINO_BET_RESPONSE | Host → Iframe | Approve or reject a bet request |
| CASINO_SESSION_REFRESH | Host → Iframe | Pass new JWT token for re-authentication |
| SOLX_READY | Iframe → Host | Iframe loaded and ready for messages |
| SOLX_BET_REQUEST | Iframe → Host | Player wants to place a bet |
| SOLX_BET_CONFIRMED | Iframe → Host | Bet confirmed by backend |
| SOLX_PAYOUT_DUE | Iframe → Host | Market resolved, winnings ready for payout |
| SOLX_AUTH_REQUIRED | Iframe → Host | JWT authentication needed to continue |
TraderHero — PostMessage Protocol
TraderHero uses a separate, non-versioned protocol. Messages are plain objects without the version: "1.0" wrapper.
| Message | Direction | Description |
|---|---|---|
| jackpot_balance_response | Host → Iframe | Send/confirm balance (on load, after debit/credit) |
| jackpot_settings | Host → Iframe | Configure RTP (50–99) for the game session |
| jackpot_theme_update | Host → Iframe | Apply CSS variables for white-label theming |
| jackpot_banner_update | Host → Iframe | Set banner ads (bottom/left/right, image or HTML) |
| jackpot_balance_request | Iframe → Host | Request current balance (sent on iframe load) |
| jackpot_balance_deduct | Iframe → Host | Deduct bet amount from player balance |
| jackpot_balance_credit | Iframe → Host | Credit payout to player balance |
Webhook Integration
When webhook mode is enabled, Solex sends HTTP POST requests to your configured webhook URL for every financial event. This applies to both Prediction Markets and TraderHero.
Webhook Events
| Event | When | Game Types |
|---|---|---|
| deposit | Player places a bet — deduct from balance | Both |
| win | Player wins — credit the payout | Both |
| refund | Market cancelled or event voided — return the bet | Prediction Markets |
Webhook Payload
{
"event": "deposit" | "win" | "refund",
"transaction_id": "uuid-v4", // Unique per webhook — use for idempotency
"timestamp": "2026-03-02T12:00:00Z",
"casino_id": "partner-uuid",
"user_id": "external-user-id",
"amount": 100.00,
"currency": "USD", // Currency from partner config
"metadata": {
// Prediction Markets:
"market_id": "uuid",
"market_title": "...",
"bet_id": "uuid",
"outcome": "YES",
// TraderHero:
"game_type": "jackpot",
"round_id": "uuid",
"bet_amount": 25,
"payout_amount": 50,
"target_rtp": 90
}
}Expected Response
{
"status": "success" | "failure",
"balance": 1400.00, // Updated balance after operation
"reason": "insufficient_balance" // Only on failure
}Every webhook includes a unique transaction_id. Your server should use this to ensure idempotent processing — if you receive the same transaction_id twice (e.g. due to retries), return the same response without double-processing.
Security Headers
Verify signatures using HMAC-SHA256: HMAC(secret, "{timestamp}.{body}"). The signing key is your webhook_signing_key (or api_secret as fallback).
Retry Policy
Failed webhooks are retried up to 4 times with exponential backoff: 5s, 30s, 2min. Each retry uses the same transaction_id but a fresh signature.
Currency Support
Currency is configured per partner. All bets, payouts, and webhook amounts use the partner's configured currency.
// Set during partner registration
POST /api/v1/casino/auth/register
{
"name": "My Casino",
"defaultCurrency": "EUR", // USD, EUR, GBP, BTC, etc.
...
}
// Or update later
PATCH /api/v1/casino/admin/config
Headers: X-Casino-Key: your_key
{
"defaultCurrency": "BTC"
}
// Currency flows through to:
// - Webhook payloads (currency field)
// - Transaction records
// - Prediction Markets SDK (CASINO_INIT balance.currency)
// - TraderHero (jackpot round currency field)JWT Authentication
JWT tokens authenticate players for the webhook flow. The same JWT system works for both Prediction Markets and TraderHero. Configure either a shared HMAC secret or a verification URL on your partner settings.
JWT Payload
{
"sub": "external_user_id", // Required: your user ID
"name": "Player Display Name", // Optional: shown in UI
"iat": 1709400000,
"exp": 1709403600,
"casino_id": "partner-uuid" // Your partner ID
}Verification Endpoint
POST /api/v1/casino/auth/verify-jwt
Content-Type: application/json
{
"jwt": "<token>",
"casinoId": "<partner-uuid>"
}
// Success response
{
"valid": true,
"user": {
"id": "internal-uuid",
"displayName": "Test Player",
"externalUserId": "external_user_id"
},
"session": {
"token": "solex_session_...",
"expiresAt": "2026-03-02T13:00:00Z"
}
}Passing JWT to Iframes
sdk.refreshSession(jwtToken)Sends CASINO_SESSION_REFRESH message to iframe
iframe.postMessage({ type: 'jackpot_settings', jwt: token }, '*')JWT passed alongside balance/settings messages
Transaction Ledger
All financial activity is tracked in the transaction ledger. Each transaction has a unique ID and links back to the originating bet or jackpot round.
| Type | Direction | Game | When |
|---|---|---|---|
| bet_placed | Debit | Prediction Markets | Player places a market bet |
| payout | Credit | Prediction Markets | Market resolves in player's favor |
| bet_refund | Credit | Prediction Markets | Market cancelled, bet returned |
| fee_collection | Debit | Prediction Markets | Casino/platform fees collected |
| jackpot_bet | Debit | TraderHero | Player enters a jackpot round |
| jackpot_payout | Credit | TraderHero | Player wins a jackpot round |
Query the ledger via GET /api/v1/casino/admin/reports/transactions with your API key. Both game types appear in the same ledger.