Skip to main content

attachFlowSource

Attaches a payment source — wallet or exchange — to a flow. Returns the updated flow and a session token that authenticates all subsequent calls for this flow.

Usage

import { attachFlowSource } from '@dynamic-labs-sdk/client';

const { flow, sessionToken } = await attachFlowSource({
  flowId: 'your-flow-id',
  fromAddress: '0xYourWalletAddress',
  fromChainId: '1',
  fromChainName: 'EVM',
  sourceType: 'wallet',
});

Parameters

This is a discriminated union on sourceType:

Wallet source (sourceType: 'wallet')

ParameterTypeDescription
flowIdstringThe flow ID.
sourceType'wallet'Indicates a wallet source.
fromAddressstringThe wallet address funding the flow.
fromChainNameChainChain family: 'EVM', 'SOL', 'BTC', 'SUI', 'TRON'.
fromChainIdstring (optional)Network ID (e.g., '1' for Ethereum, '8453' for Base).

Exchange source (sourceType: 'exchange')

ParameterTypeDescription
flowIdstringThe flow ID.
sourceType'exchange'Indicates an exchange source.
exchangeProvider'coinbase'The exchange provider.

Returns

Promise<FlowSourceResponse>:
type FlowSourceResponse = {
  flow: Flow;
  sessionToken: string;
};
The SDK stores the session token automatically — you do not need to pass it to subsequent flow calls.

Examples

Wallet source (EVM)

import { attachFlowSource } from '@dynamic-labs-sdk/client';

const { flow } = await attachFlowSource({
  flowId: 'your-flow-id',
  fromAddress: '0xYourWalletAddress',
  fromChainId: '8453',
  fromChainName: 'EVM',
  sourceType: 'wallet',
});

Wallet source (Solana)

import { attachFlowSource } from '@dynamic-labs-sdk/client';

const { flow } = await attachFlowSource({
  flowId: 'your-flow-id',
  fromAddress: 'YourSolanaAddress',
  fromChainId: '101',
  fromChainName: 'SOL',
  sourceType: 'wallet',
});

Exchange source (Coinbase)

import { attachFlowSource } from '@dynamic-labs-sdk/client';

const { flow } = await attachFlowSource({
  flowId: 'your-flow-id',
  sourceType: 'exchange',
  exchangeProvider: 'coinbase',
});

// Open the exchange buy URL for the user
const exchangeUrl = flow.exchangeSource?.metadata?.url;