Flow is an enterprise feature. Contact us to enable it for your environment.
Prerequisites
Before this page: a connected wallet (see Connecting external wallets) for the wallet payment path. Your backend creates the flow and passes itsflowId to the frontend — flow creation is server-side; this page covers the frontend.
What you’ll build
A Flow deposit takes a payment from a user’s wallet or an exchange and settles it to a destination. The frontend walks the flow through its lifecycle:- Load the flow and check it’s still actionable.
- Attach a source — a wallet or an exchange.
- Quote — lock in amounts and fees.
- Sign & submit (wallet) or confirm (exchange).
- Track to settlement.
executionState and settlementState are string unions you branch on at every step.
Load the flow
ReadflowId (typically from the URL so a user can resume) and load it with getFlow. Skip the UI when the flow has already reached a terminal state.
- TypeScript
- React
Attach a payment source
attachFlowSource records where the payment comes from. For a wallet, pass the user’s address and chain. For an exchange, pass the provider — the response’s flow carries the hosted buy URL to open.
- TypeScript
- React
Quote the flow
getFlowQuote returns the flow with a quote — fromAmount, toAmount, fees, and estimatedTimeSec. Quotes expire (quote.expiresAt), so let the user re-quote before signing. Omit fromTokenAddress to pay in the chain’s native token.
- TypeScript
- React
Sign and submit (wallet)
submitFlowTransaction runs the whole signing pipeline — prepare, approve (if the token needs an allowance), sign, and broadcast. onStepChange fires 'approval' then 'transaction' so you can show progress.
- TypeScript
- React
broadcastFlow({ flowId }) to tell the backend the transfer was made.
Track to settlement
PollgetFlow until it settles. executionState covers the on-chain leg (broadcasted → source_confirmed); settlementState covers delivery (settling → completed). Stop when either terminates.
- TypeScript
- React
Cancelling
Before broadcast, a user can back out withcancelFlow({ flowId }). After broadcast the transaction is on-chain and can’t be reversed — hide the cancel entry point once executionState reaches broadcasted.
Handling errors
See also
- Connecting external wallets — connect the wallet used to pay
- Network switching & validation — put the wallet on the right network
- Token balances & display — pick the token to pay with