> ## 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.

# getSwapChains

> List the chains and networks your users can swap tokens on.

## Overview

`getSwapChains` returns the networks where tokens can be swapped for your environment. Use it to build a network picker instead of hardcoding a list, then pass a network to [`getSwapTokens`](https://www.dynamic.xyz/docs/javascript/reference/client/get-swap-tokens) to list its tokens.

The list respects your environment's swap settings and can differ by the user's region, so a network that can't be swapped on is not returned. Networks that this SDK version does not support are also left out.

## Usage

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

const { chains } = await getSwapChains();

for (const network of chains) {
  console.log(network.displayName, network.chain, network.networkId);
}
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `client` | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple clients. |

## Returns

`Promise<SwapChainsResponse>`: an object with a `chains` array. Each entry is a `SwapCatalogChain`:

| Field | Type | Description |
| - | - | - |
| `chain` | `Chain` | The chain the network belongs to (for example, `'EVM'` or `'SOL'`). |
| `networkId` | `string` | The network ID to pass to `getSwapTokens` and `getSwapQuote`. |
| `displayName` | `string` | A human-readable network name, such as `'Base'`. |
| `iconUrl` | `string` (optional) | A URL for the network's icon. |

If no swap provider is available for your environment or the user's region, `chains` is an empty array.

## Examples

### Show only the networks of the user's wallet

A swap uses one wallet, so offer only the networks on that wallet's chain.

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

const getWalletSwapNetworks = async (walletAccount) => {
  const { chains } = await getSwapChains();

  return chains.filter((network) => network.chain === walletAccount.chain);
};
```

## React

`useGetSwapChains` returns the same list in `data`.

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

function SwapNetworkList() {
  const { data, isLoading, error } = useGetSwapChains();

  if (isLoading) {
    return <p>Loading networks...</p>;
  }

  if (error) {
    return <p>Could not load networks: {error.message}</p>;
  }

  return (
    <ul>
      {data?.chains.map((network) => (
        <li key={`${network.chain}:${network.networkId}`}>
          {network.displayName}
        </li>
      ))}
    </ul>
  );
}
```

## Related

* [`getSwapTokens`](https://www.dynamic.xyz/docs/javascript/reference/client/get-swap-tokens): list the tokens on a network
* [`getSwapQuote`](https://www.dynamic.xyz/docs/javascript/reference/client/get-swap-quote): quote a swap between two tokens


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