Skip to content

How this demo is wired

For developers: the operator-side calls behind this site

1. The session is minted on the server

The tenant API key stays in this server. Before it draws a page it calls POST /v1/widget/sessions on the operator API with { "external_user_id": "...", "site": "demo-operator" }, and the page gets only the returned token, which it passes to PredictionMarketWidget.mount({ sessionToken }). A signed-in demo account mints for its own player; the studio preview, which has no login, mints for a blocked helper user. A visitor who has not logged in gets an anonymous session, minted with { "anonymous": true, "site": "demo-operator" } on every page load: the widget shows the markets and their live prices, refuses every trade, and its log-in button calls onLoginRequest, which opens this site's login.

Demo shortcut: one token is reused across visits until 6 minutes before it expires. The integration guide says to mint a new token on every page load; do that in production. Getting started

2. The money stays in this site's wallet

A sign-up registers the player with PUT /v1/users/{external_user_id}. The player's money is held here, in this site's own wallet, and Predixum calls that wallet for every move of it: it posts to /wallet/debit before it accepts a stake, to /wallet/credit after a payout, a close or a refund, to /wallet/rollback when a debited stake did not become a position, and to /wallet/balance for the balance the widget shows. Each call carries X-Wallet-Signature, sha256= and the hex HMAC-SHA256 of the raw body under the wallet secret, which this site checks before it reads anything.

The wallet answers a repeated transaction_id with its first answer, byte for byte, and moves no money twice. A rollback answers ok even for a debit it never saw, and keeps the id, so a late debit with it is refused with debit_rejected. A resettlement or reversal debit is always answered ok; what the player cannot cover, the site absorbs, and the Profile page shows it.

The Deposit page plays the operator's cashier: it credits the wallet under a key made when the form is drawn, so a resubmitted form credits once. "Try as demo player" signs in one shared player per site with an opening balance of 100.00, credited once under a fixed key.

3. Widget callbacks

  • onDepositRequest({ marketSlug, stake }): the player pressed Deposit on a stake above the balance. This site opens its deposit page with the stake, rounded up, already filled in, and links back to the market after the credit.
  • onPositionOpened and onPositionClosed: the header balance is read again at once.
  • onReady: called once, when the widget first draws a view from loaded data. This demo does not use it; an operator would remove its own loading placeholder there.
  • onRouteChange with hostNavigation: true: the site owns the address bar, so /m/{slug} and /portfolio survive a reload.

Widget reference

4. Webhook receiver

The platform posts signed events to /webhooks on this site. The receiver checks X-Webhook-Signature, which is sha256= and the hex HMAC-SHA256 of the raw body under the webhook secret, before it parses anything, answers 401 to a signature that does not match, and recognises a retried delivery by X-Webhook-Delivery. Without a secret it answers 503, so the platform keeps the delivery and tries again. The newest 200 deliveries are on the webhook log.

Webhooks

5. Theme from the card studio

The page reads the tenant config (GET /v1/widget/config) with a session of its own and paints its header, page colour, font and corner radius from the theme saved in the card studio. A visible page asks /site/config every 10 seconds and applies the look again when the config changes, so a saved theme shows without a reload. Inside the studio, unsaved edits arrive by postMessage.

6. Same-origin proxy

The widget calls relative URLs, so this server forwards /v1/*, the realtime socket /connection/* and the bundle, and no CORS allowlist is involved. Demo note: the bundle comes from /widget/v0/widget.iife.js; the integration guide documents the published /widget/v1/ path. Realtime

How this demo is wired | Lumora