Skip to main content
Use TradeWidget props to control the widget’s runtime behavior, preselected assets, and available networks or tokens.

Runtime configuration

All runtime options live under the required config prop.
By default, the widget uses https://api.delora.build. Set apiUrl when you want a custom upstream, such as your own backend proxy:
Use rpcUrls to provide preferred endpoints for a supported chain. Map each numeric chain ID to an ordered URL array; the widget tries those URLs first and keeps its default endpoints as fallbacks. For supported chain IDs, see Connected chains. If assetBaseUrl is not set, it falls back to config.apiUrl and then to https://api.delora.build. For browser-based widget integrations, prefer not to pass apiKey directly from the client. Instead:
  • keep your Delora API key on your backend
  • expose a proxy that forwards /v1/chains, /v1/tokens, /v1/tools, and /v1/quotes to https://api.delora.build
  • point config.apiUrl to that proxy
  • if your proxy does not also serve Delora relative image assets, set assetBaseUrl: "https://api.delora.build" or proxy those asset paths as well
TradeWidget already supports this pattern because all Delora API reads go through config.apiUrl. If termsUrl or privacyPolicyUrl is omitted, the connect modal falls back to:
  • ${window.location.origin}/documentation/termsofuse
  • ${window.location.origin}/documentation/privacypolicy
For third-party embeds, it is usually better to set both URLs explicitly. The consent footer is enabled by default. To remove the checkbox, links, and acceptance requirement from the connect modal, set:
When requireWalletConsent is false, termsUrl and privacyPolicyUrl are not rendered because the entire consent footer is hidden.

Configure built-in wallets

Use config.wallets to control the widget-managed wallet picker. These three fields have independent purposes:
  • include is an allowlist. When present, only listed wallets are eligible.
  • exclude is a denylist. It removes listed wallets and takes precedence over include.
  • order moves listed, enabled wallets to the front in the specified order. It does not hide unlisted wallets.
For example, offer only WalletConnect:
Or prioritize WalletConnect, MetaMask, and Solflare while keeping all other wallets except Rabby available:
Supported wallet ids are:
  • metamask
  • rabby-wallet
  • walletconnect
  • backpack
  • phantom
  • solflare
  • trust-wallet
  • okx-wallet
  • coinbase-wallet
  • magic-eden
Wallet filtering also applies to persisted built-in sessions, so an excluded or non-included wallet is not restored automatically. Namespace compatibility still applies after configuration; for example, WalletConnect is available for EVM and Solflare is available for Solana. config.wallets controls only built-in wallet management. When the host supplies walletOptions through external wallet management, that host-provided array remains the source of truth.

Initial selections

You can preselect both networks and tokens.
If an initial network or token is not available in loaded metadata, the widget reports it through onError. The same happens when a host-provided initial selection becomes invalid after filters are applied.

Lock tokens or networks

Use lock props when you want the host app to keep part of the form fixed.
Supported lock props:
  • lockSellToken
  • lockBuyToken
  • lockSellNetwork
  • lockBuyNetwork
Behavior:
  • Locking a token also locks its network, because the token already implies a chain
  • Locking a network still allows token changes inside that network
  • Any lock disables the center “swap sides” button to avoid breaking host-provided constraints

Filter available networks and tokens

Use filters to restrict the sell and buy sides independently.
Each side supports:
  • includeNetworkIds
  • excludeNetworkIds
  • includeTokens
  • excludeTokens
Important filter behavior:
  • Filters are applied per side, so sell and buy restrictions can be different
  • Networks that end up with no available tokens are removed automatically
  • Conflicting filters produce onError events with source: "configuration"
  • If no networks remain on a side after filtering, the widget enters a configuration error state

Custom token lookup

When a side does not use includeTokens, the token selector can import a token by contract or mint address if the address is valid for the active network. Imported tokens become part of the current browser session and can also be restored from persisted selection state. When includeTokens is set for a side, custom token import is disabled on that side.

Persistence

The widget stores the latest selected sell and buy networks and tokens in browser localStorage, so the next mount can restore the previous selection when the host app does not explicitly override it. Slippage and internal wallet choices are also persisted separately.

Quote lifecycle and refresh behavior

The widget does not request a quote on every keystroke. Quote loading has a small client-side lifecycle:
  • sell input is debounced by about 1 second before a quote request is sent
  • successful quotes auto-refresh every 60 seconds while the current selection stays stable
  • auto-refresh stops after 5 consecutive refresh cycles until the user changes the selection or amount
  • the quote countdown ring in the UI can also be clicked to request a manual refresh immediately
The widget also applies a local cooldown around quote refreshes to avoid excessive request loops:
  • more than 15 quote requests within 5 seconds starts a local cooldown
  • the cooldown lasts 5 seconds
  • during that window, the widget can emit onError({ source: "quote", statusCode: 429 }) even if the backend did not return 429
If you build analytics or retry logic around quote errors, treat this as widget-side throttling as well as possible API-side rate limiting.