01 / Build the connection
Listen to game messages
Handle supported messages sent from the game to its parent page.
The embedded game can report changes to its parent page through postMessage. Available messages depend on the game and release assigned to you; confirm that contract before wiring your handlers.
Balance Messages
The shared game client sends the following message when it receives a balance update:
{ type: 'balance', balance: 1234.56 }The type is lowercase balance. This message has no timestamp field. It can update a display, but must never credit or debit a wallet; signed server callbacks remain authoritative.
Receiving a Message
Give your game iframe the ID game-frame. Check both the sender's origin and its window, then validate the message shape:
const gameFrame = document.getElementById('game-frame');
const gameOrigin = 'https://games.wildvoltgames.com';
window.addEventListener('message', (event) => {
if (event.origin !== gameOrigin || event.source !== gameFrame?.contentWindow) return;
const data = event.data;
if (!data || typeof data !== 'object' || data.type !== 'balance') return;
if (typeof data.balance !== 'number' || !Number.isFinite(data.balance)) return;
// Update your balance display only, using the agreed currency formatting.
updateBalanceDisplay(data.balance);
});Use the exact origin assigned to your environment. Do not accept every origin or use a substring check.
Other Events
GAME_READY, ERROR, and BALANCE_UPDATE are not part of this shared-client contract. Do not depend on them unless your supplied game release has a separately documented interface. An iframe load event confirms document loading, not a successfully authenticated or playable game session.
Do not log launch tokens or full message payloads. Browser messages are untrusted display signals, not settlement or reconciliation evidence.