Skip to main content
Attaches a payment source to a flow: a wallet, an exchange, or a deposit address. Attaching issues the flow’s session token, and the SDK stores it on the device. Every later action on the flow, such as quoting, submitting, or cancelling, sends that token automatically.

When to call

Call attachFlowSource when executionState is initiated, source_attached, quoted, or signing. Attaching again before the payment is sent replaces the source, so the payer can change how they pay. Each attach issues a new session token, and the previous token stops working. Attaching from signing requires the current session token, so it works only on the device that attached the source before. A flow in signing may already have a payment approved in the wallet. Attaching needs no session token in the other states. That is how a payer on another device, or with cleared storage, resumes before the payment is sent. Read the flow with getFlow first and attach only when its state allows it.

Usage

Parameters

The parameters depend on sourceType. Payment sources explains each source.

Wallet source

The payer pays from a connected wallet. Dynamic screens the wallet address when it is attached.
The SDK’s TypeScript type marks fromChainId as optional for wallet sources, but the request fails without it. Always pass it.

Exchange source

The payer pays from an exchange account, such as Coinbase, through a purchase link. Dynamic does not screen exchange sources.

Deposit address source

The payer sends funds to an address generated for the payment, from any wallet or exchange. Dynamic does not screen deposit-address sources. Deposit addresses support EVM chains, Solana, Bitcoin, and TRON. The address arrives with the quote, so call getFlowQuote next. Do not pass fromAddress with a deposit-address source; the request is rejected. Dynamic does not initiate refunds, and a refund can fail, as described in Failures and refunds.

Returns

Promise<FlowSourceResponse>:

Examples

Wallet on Solana

Exchange

Attaching the exchange again issues a new purchase link. A purchase already completed through an earlier link can still reach your destination.

Deposit address

Errors

Attaching from signing without the current session token is rejected with error.code session_token_invalid. Show the flow as processing instead, because the payment may already have been approved. Handle Flow errors describes each error and how to recover.

React

useAttachFlowSource is a mutation hook. It takes the same parameters, and it writes the returned flow into the useGetFlow cache.
Last modified on October 28, 2026