Skip to content
TokenFlight SDK

Transaction Lifecycle

The TokenFlight widget follows this phase model. Understanding this lifecycle helps you build appropriate UI feedback and handle edge cases.

idle → quoting → quoted → building → awaiting-wallet → submitting → tracking → success
↑ ↑ │
├───────┴──────────────────── error ←───────────────────────────────────────────┘
└─────────────────────────── success

From error, the widget can return to idle (fresh start) or quoting (retry with same inputs).

PhaseWhat HappensCancel?Duration
idleWidget ready; user selecting tokens/amounts
quotingPOST /v1/quotes — fetching routesYes1–5 s
quotedRoutes displayed; user reviews and selectsYesUser action
buildingPOST /v1/deposit/build — constructing wallet actionsNo< 2 s
awaiting-walletWallet popup; waiting for signatureYesUser action
submittingPUT /v1/deposit/submit — submitting tx hashNo< 2 s
trackingGET /v1/orders/:address — polling for completionNo10 s – 10 min
successOrder filled; funds arrivedReset

Each swap follows a four-step API lifecycle:

POST /v1/quotes

Requests cross-chain swap quotes. The API returns one or more route options from providers like Across, DeBridge, Glacis, or Hyperstream’s native router.

POST /v1/deposit/build

Takes the selected route and returns a sequence of wallet actions to execute (token approvals, contract calls, etc.). Each action includes the chain ID, method, and parameters needed for the wallet.

PUT /v1/deposit/submit

After the user signs the transaction in their wallet, the SDK submits the transaction hash to the API. This creates an order and begins tracking.

GET /v1/orders/:address

Polls for order status. Uses progressive polling intervals to balance responsiveness with API load:

Time Since SubmitPoll Interval
0–10 secondsEvery 1 second
10–30 secondsEvery 2 seconds
30–60 secondsEvery 3 seconds
60–120 secondsEvery 5 seconds
120+ secondsEvery 10 seconds

Errors can occur at any phase. Most execution/configuration failures transition the widget to error and invoke onSwapError.

If an error occurs before the user signs (phases: quoting, quoted, building), no funds have left the wallet. The widget can safely return to idle for a retry.

If the transaction was signed and broadcast but the order fails (phases: submitting, tracking), funds may have been sent. The SwapErrorData includes details you can use to investigate:

  • Use the txHash from the onSwapSuccess callback to check the transaction on the source chain’s block explorer.
  • Query GET /v1/orders/:address from your backend to check the order status.

From the error phase, the widget can transition to:

  • idle — reset and start over
  • quoting — retry with a new quote
  • quoted — return to route selection (if the quote is still valid)

When the user rejects the wallet signature prompt, the widget transitions from awaiting-wallet to error. In current adapters, this is commonly surfaced as TF2003 (WALLET_ACTION_FAILED) with a rejection message from the wallet.

  • API requests: 15-second timeout. If the API does not respond, the widget transitions to error with code TF3002 (API_TIMEOUT).
  • No automatic retry: The SDK uses retry: 0 for API requests. Users must manually retry by interacting with the widget.