Skip to main content
TradeWidget exposes callbacks for quote resolution, wallet connections, transaction lifecycle reporting, and error handling.

Example

<TradeWidget
  config={{}}
  onQuote={(payload) => {
    console.log("quote", payload);
  }}
  onConnect={(payload) => {
    console.log("wallet connected", payload);
  }}
  onTxSubmitted={(payload) => {
    console.log("submitted", payload.action, payload.txHash);
  }}
  onTxConfirmed={(payload) => {
    console.log("confirmed", payload.action, payload.txHash);
  }}
  onError={(payload) => {
    console.error(payload.source, payload.message);
  }}
/>

Supported callbacks

CallbackWhen it firesPayload
onQuoteAfter a new quote is resolvedTradeWidgetQuotePayload
onConnectAfter a wallet connection succeedsTradeWidgetConnectPayload
onApproveWhen the widget submits a standalone approval transactionTradeWidgetTransactionPayload
onSwapWhen the widget submits a swap transactionTradeWidgetTransactionPayload
onTxSubmittedWhen any approval or swap transaction is submittedTradeWidgetTransactionPayload
onTxConfirmedWhen a submitted transaction is confirmedTradeWidgetTransactionPayload
onErrorWhen metadata, configuration, selection, quote, wallet, balances, execution, or unsupported errors occurTradeWidgetErrorPayload

Event behavior notes

  • onQuote is deduplicated, so identical resolved quotes are not emitted repeatedly
  • onQuote can fire after the initial quote load, a manual refresh, or an auto-refresh when the resolved quote changed
  • onConnect only reports namespace, address, and walletName; it does not identify whether the connection came from the origin or destination side
  • onApprove and onSwap are submission hooks, not simple button-click hooks
  • onTxSubmitted is the generic submission event for both approve and swap
  • onTxConfirmed is the generic confirmation event for both approve and swap
  • onError with source: "quote" and statusCode: 429 can come either from the Delora API or from the widget’s own local quote cooldown
In batched EVM flows that combine approval and swap into a single EIP-5792 call, the widget may only emit the swap-side transaction event because there is no separate approval transaction hash. The widget also applies a local quote lifecycle around refreshes:
  • successful quotes auto-refresh every 60 seconds while the selection stays stable
  • auto-refresh stops after 5 consecutive refresh cycles
  • more than 5 quote requests within 5 seconds triggers a local cooldown
  • the cooldown lasts 5 seconds
  • during that window, onError can emit a quote error with statusCode: 429 even if the backend did not return 429

Error sources

onError can report the following source values:
  • metadata
  • configuration
  • quote
  • selection
  • wallet
  • balances
  • execution
  • unsupported
The payload can also include status, statusCode, and the original error object.