> ## Documentation Index
> Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# getFlowSourceTokenOptions

> List the networks and tokens a payer can fund a Flow payment from with a deposit address, using the JavaScript SDK.

Lists the networks and tokens a payer can fund a flow from with a deposit address. Show them when the payer chooses to pay to a deposit address, then attach the network they pick with [`attachFlowSource`](https://www.dynamic.xyz/docs/javascript/reference/client/attach-flow-source) and quote the token they pick with [`getFlowQuote`](https://www.dynamic.xyz/docs/javascript/reference/client/get-flow-quote). `getFlowSourceTokenOptions` needs no session token.

Each option is one network with its chain family and the tokens accepted on it. A network on a chain family that your SDK version does not recognize is left out of the list. [Payment sources](https://www.dynamic.xyz/docs/flow/payment-sources.md) explains deposit-address payments.

## Usage

```javascript theme={"system"}
import { getFlowSourceTokenOptions } from '@dynamic-labs-sdk/client';

const sourceTokenOptions = await getFlowSourceTokenOptions({
  flowId: 'your-flow-id',
  sourceType: 'deposit_address',
});

sourceTokenOptions.forEach(({ network, tokens }) =>
  console.log(network.name, tokens.map(({ symbol }) => symbol))
);
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `flowId` | `string` | The flow ID. |
| `sourceType` | `'deposit_address'` | The payment source to list tokens for. Only `'deposit_address'` is supported. |

## Returns

`Promise<FlowSourceTokenOption[]>`:

| Field | Type | Description |
| - | - | - |
| `chain` | `{ name: Chain; iconUrl?: string }` | The network's chain family, for example `'EVM'` or `'SOL'`, and the URL of its logo. Pass `name` as `fromChainName` to `attachFlowSource`. |
| `network` | `{ id: string; name: string; iconUrl?: string }` | The network's ID within its chain family, for example `'8453'` for Base, its display name, and the URL of its logo. Pass `id` as `fromChainId`. |
| `tokens` | `{ address: string; decimals: number; symbol: string; iconUrl?: string }[]` | The tokens the payer can send on the network. Pass a token's `address` as `fromTokenAddress` to `getFlowQuote`. |

A token's `address` is its contract address, or a chain-specific placeholder for the network's native token.

## Examples

### Attach and quote the token the payer picks

```javascript theme={"system"}
import { attachFlowSource, getFlowQuote, getFlowSourceTokenOptions } from '@dynamic-labs-sdk/client';

const sourceTokenOptions = await getFlowSourceTokenOptions({
  flowId: 'your-flow-id',
  sourceType: 'deposit_address',
});
const [{ chain, network, tokens }] = sourceTokenOptions; // The payer's network
const [token] = tokens; // The payer's token

await attachFlowSource({
  flowId: 'your-flow-id',
  sourceType: 'deposit_address',
  fromChainName: chain.name,
  fromChainId: network.id,
  refundAddress: '0xPayerRefundAddress',
});

const flow = await getFlowQuote({
  flowId: 'your-flow-id',
  fromChainId: network.id,
  fromTokenAddress: token.address,
});

console.log(`Send ${token.symbol} to ${flow.depositAddress}`);
```

[Build a custom payment UI](https://www.dynamic.xyz/docs/javascript/reference/flow-ui-guide.md#deposit-address) shows how to build a QR code payment URI and refresh the quote every 60 seconds.

## Errors

| Error | When |
| - | - |
| `FlowNotFoundError` | The flow does not exist in the client's environment. |

## React

`useGetFlowSourceTokenOptions` fetches the list once per flow and source, and stays disabled until `flowId` is defined. Override the caching with `queryParams.staleTime`.

```tsx theme={"system"}
import { useGetFlowSourceTokenOptions } from '@dynamic-labs-sdk/react-hooks';

function DepositTokenList({ flowId, onSelect }) {
  const { data: sourceTokenOptions = [], isLoading } = useGetFlowSourceTokenOptions({
    flowId,
    sourceType: 'deposit_address',
  });

  if (isLoading) return <p>Loading...</p>;
  return sourceTokenOptions.flatMap(({ chain, network, tokens }) =>
    tokens.map((token) => (
      <button key={`${network.id}:${token.address}`} onClick={() => onSelect({ chain, network, token })}>
        {token.symbol} on {network.name}
      </button>
    ))
  );
}
```

## Related

* [`attachFlowSource`](https://www.dynamic.xyz/docs/javascript/reference/client/attach-flow-source): attach the deposit address as the payment source.
* [`getFlowQuote`](https://www.dynamic.xyz/docs/javascript/reference/client/get-flow-quote): quote the token and get the deposit address.
* [Payment sources](https://www.dynamic.xyz/docs/flow/payment-sources.md): how deposit-address payments work.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.