Setting Default Token & Chain

Preselect what the widget shows on load using URL parameters.

Overview

The initial destination chain and token are set with dstChainId and dstToken in the iframe URL. Both are plain, URL‑encoded strings (dstChainId is a chain ID; dstToken is an ERC‑20 address). If either value is invalid or the token isn’t available on that chain, the widget falls back to its built‑in defaults.

See Supported Chains

Usage Example

// In your JavaScript when configuring the widget:
const integratorId = "xxx";  // Your actual integrator ID
const dstChainId = "1"
const dstToken = "0x8fe815417913a93ea99049fc0718ee1647a2a07c";

const IFRAME_BASE_URI = "https://app.swapper.finance";
const iframe = document.getElementById("swapperFinanceWidget");  

// Build query string
const queryParams = new URLSearchParams({
  integratorId,
  dstChainId,
  dstToken
}).toString();

// Assign to iframe
if (iframe) {
  const iframeSrc = `${IFRAME_BASE_URI}?${queryParams}`;
  iframe.src = iframeSrc
  console.log("Swapper Finance Widget: URL configured with query parameters.");
  console.log("Full URL:", iframeSrc);
} else {
  console.error("Iframe element not found: please ensure its id is 'swapperFinanceWidget'.");
}

Last updated