SwapWidget to ship same-chain and cross-chain swap UX quickly while your host app still owns signing and transaction submission.
Install
Use the same package set and the sameDeframeProvider wrapper as EarnWidget:
Use the Pods Wallet-style swap view by overriding
SwapFormView with PodsSwapFormView. Import DeframeProvider, EarnWidget, and SwapWidget from pods-sdk so the widgets share the same React context.Styles and Theme
SwapWidget follows the same styling model as EarnWidget:
- Import
@deframe-sdk/components/styles.cssonce in the host app entrypoint. - Keep host CSS scoped and avoid global resets leaking into
.deframe-widget. - Configure branding through
DeframeProvider.config.theme. - Use
.deframe-widgetCSS variables only from a wrapper you own.
Render SwapWidget
MountSwapWidget inside the shared DeframeProvider wrapper from the Earn guide.
Use the Pods Wallet Swap View
RegisterPodsSwapFormView at the provider level so every SwapWidget renders the Pods Wallet-style view: title and subtitle, history action, two token amount cards, the centered direction button, and the primary action button state.
DeframeProvider, not on each swap page. The page still renders the SDK widget normally with <SwapWidget />; the provider decides which swap form view is used.
Prefill Token/Chain Params
You can initialize swap inputs from host route or query params. This is the pattern to use when another widget or dashboard card sends the user into swap with a target token already selected.SwapWidget Props
API Endpoints Used in Swap Flows
GET /v2/swap/quoteto request same-chain/cross-chain quotesPOST /v2/swap/bytecodeto build executable transaction payloadsGET /v2/swap/status/{id}to track cross-chain swap lifecycle
Cross-chain Lifecycle Recommendations
- Generate quote and bytecode.
- Execute all returned bytecodes in order through
processBytecode. - Persist
quoteIdandclientTxIdin your backend. - Poll the swap status endpoint until the flow reaches a terminal state.
- Display status history in customer support/admin surfaces.
Transaction Bridge
SwapWidget uses the same processBytecode contract as EarnWidget.
See processBytecode Contract for required status emissions and error mapping.