Phoenix Prediction Docs

Parent Bridge

Events between the iframe and the operator page

The Phoenix Prediction iframe does not own login, registration, cashier, or deposit flows. When it needs one of those actions, it sends an event to the parent page.

All postMessage handling must validate origins on both sides.

Iframe to Parent

EventWhen it happensParent behavior
phoenix:readyIframe has loaded and can receive parent messagesStore the iframe reference or clear loading UI
phoenix:resizeAuto sizing is enabled and content height changesUpdate iframe height
phoenix:authRequiredVisitor clicked a player-only actionOpen login/register and mint a player token
phoenix:depositRequestedPlayer needs funds to complete an actionOpen cashier/deposit
phoenix:tokenExpiringCurrent launch token is near expiryMint and send a fresh token
phoenix:betPlacedA bet was acceptedOptional analytics or parent UI refresh
phoenix:errorIframe hit an integration-facing errorLog and show support path when needed

Parent to Iframe

EventPurpose
phoenix:setTokenReplace visitor token with player token, or refresh an expiring token
phoenix:navigateAsk iframe to navigate to a Phoenix Prediction route or market
phoenix:refreshAsk iframe to reload its Phoenix Prediction data

Visitor to Player Flow

1. Iframe starts with a visitor JWT.
2. Visitor clicks Buy.
3. Iframe sends phoenix:authRequired.
4. Your site completes login or registration.
5. Your backend mints a player JWT.
6. Parent sends phoenix:setToken to the iframe.
7. Iframe reconnects as the player.

Example Listener

const iframe = document.querySelector<HTMLIFrameElement>('#phoenix-prediction-embed');
const phoenixOrigin = 'https://embed.prediction.phoenixverse.io';

window.addEventListener('message', async (event) => {
  if (event.origin !== phoenixOrigin) return;
  if (!event.data || typeof event.data.type !== 'string') return;

  switch (event.data.type) {
    case 'phoenix:authRequired': {
      const token = await loginAndMintPhoenixPredictionToken();
      iframe?.contentWindow?.postMessage(
        { type: 'phoenix:setToken', token },
        phoenixOrigin,
      );
      break;
    }

    case 'phoenix:depositRequested':
      openCashier();
      break;

    case 'phoenix:resize':
      if (typeof event.data.height === 'number' && iframe) {
        iframe.style.height = `${event.data.height}px`;
      }
      break;
  }
});

Security Requirements

  • Check event.origin before trusting any message.
  • Send messages back to the exact Phoenix Prediction origin, not *.
  • Keep allowed parent origins configured in Phoenix Prediction admin.
  • Do not send private account or wallet data through bridge messages unless Phoenix explicitly documents the field.

On this page