Webview Base URL
Iframe URL Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
smartAccountAddress | 0x${string} | Yes | The user’s smart account address |
chainId | number | Yes | Target chain ID (e.g., 137 for Polygon) |
theme | string | Yes | UI theme ("dark" or "light") |
preset | string | Yes | Widget preset (e.g., "cryptocontrol") |
deframeApiUrl | string | Yes | Deframe API base URL |
deframeApiKey | string | Yes | Deframe API key |
alchemyPolicyId | string | Yes | Alchemy gas policy ID (for paymaster) |
alchemyRpcId | string | Yes | Alchemy RPC/API key |
widget | "earn" | "swap" | No | Which widget to display (defaults to "earn") |
URL Builder Example
postMessage Protocol
The iframe and wrapper communicate viawindow.postMessage. The protocol is typed in TypeScript below — copy this into your project as src/types/postmessage-protocol.ts.
Shared Types
Message Directions
Type Guards
processBytecode Flow via postMessage
The iframe version ofprocessBytecode works over postMessage instead of in-process callbacks. The transaction lifecycle statuses and error handling are the same as the widget processBytecode — the only difference is the transport: messages are wrapped in { kind: 'TX_STATUS_UPDATE', payload } and sent via postMessage instead of calling ctx.updateTxStatus() directly.
Happy Path
Error Paths
See processBytecode — Error Handling for the full list of error statuses (SIGNATURE_DECLINED, SIGNATURE_ERROR, TX_REVERTED).
Listening for postMessage Events
The wrapper must listen formessage events on window and filter using the type guards from the protocol types:
Iframe HTML Element
Wrapper Implementations
We provide two reference wrapper implementations, each targeting a different wallet/auth stack:wagmi + viem
Browser wallet (MetaMask) with ERC-4337 smart accounts via
permissionless. Single-chain (Polygon).Privy
Privy authentication (email OTP) with embedded smart wallets. Multi-chain support (6 chains).
LLM Resources
Use these resources to generate iframe wrapper projects with AI assistants.One-Shot Prompts
| Resource | Stack | Use |
|---|---|---|
/llms-iframe-wagmi-viem.txt | wagmi + viem + permissionless | Generate a complete iframe wrapper with browser wallet + ERC-4337 |
/llms-iframe-privy-multichain.txt | Privy + multi-chain | Generate a complete iframe wrapper with Privy auth + 6-chain support |