Preview sandbox & wallet bridge

How previews are isolated and how they still reach your wallet. This page is part of the Building apps chapter of the TokenOS documentation.

How the wallet bridge works

The chip

The header chip above the preview shows the bridge state — off , pending , allowed , denied — and is clickable: pre-allow before the app asks, revoke an allowed project, or reset a denial.

Inside the generated app

hooks/useWallet.js wraps this for React and hands pages a plain address string. RPC reads go through /api/solana-rpc (an allow-listed proxy) so no API key is ever present in client code.

, <>Every served preview HTML receives a small inline script providing memory-backed <Code>localStorage</Code> / <Code>sessionStorage</Code> and bridged <Code>window.solana</Code>, <Code>window.phantom.solana</Code> and <Code>window.ethereum</Code> providers. Outside the IDE the shim is a no-op and the app talks to the browser

connect · disconnect · signMessage · signTransaction · signAllTransactions · signAndSendTransaction · request

ethereum.request (eth_requestAccounts, eth_chainId, eth_sendTransaction, personal_sign, wallet_switchEthereumChain, wallet_addEthereumChain …), enable, send, sendAsync

eth_sign · eth_signTransaction (raw signing is never relayed)

Never add allow-same-origin to a preview iframe.

Design Mode and bridge messages are accepted only from the preview iframes (origin and source checks).

Nothing is relayed before the builder clicks Allow; a denial is remembered for the session.

Protected runtime files (config.js, lib/web3.js, lib/walletBridge.js, hooks/useWallet.js) are never rewritten by the sanitizers.

Browse the full TokenOS documentation or jump to the API reference, credits & pricing or FAQ.

About TokenOS

TokenOS is the AI operating system for the autonomous Web3 economy. It combines an agentic IDE that turns a prompt into a deployed dApp, a marketplace of x402-paid AI agents, a peer-to-peer AI inference market where anyone can sell spare API quota or GPU time for USDC, MCP and A2A connectors for Claude, Cursor and ChatGPT, and the $TOS utility and governance token on Solana.

Builders pay with prepaid credits; sellers and agent creators are paid for work actually delivered; TokenOS indexes, verifies and settles. Nothing on this site is investment advice, and node payouts, agent payments and referral credits are fees for usage — not token distributions or returns.