Skip to main content
Use 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 same DeframeProvider 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.css once 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-widget CSS variables only from a wrapper you own.
See EarnWidget Styles and Theme for the full CSS example.

Render SwapWidget

Mount SwapWidget inside the shared DeframeProvider wrapper from the Earn guide.

Use the Pods Wallet Swap View

Register PodsSwapFormView 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.
Keep this override in the wrapper that owns 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/quote to request same-chain/cross-chain quotes
  • POST /v2/swap/bytecode to build executable transaction payloads
  • GET /v2/swap/status/{id} to track cross-chain swap lifecycle
Guides:

Cross-chain Lifecycle Recommendations

  1. Generate quote and bytecode.
  2. Execute all returned bytecodes in order through processBytecode.
  3. Persist quoteId and clientTxId in your backend.
  4. Poll the swap status endpoint until the flow reaches a terminal state.
  5. 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.