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

# getMoonPayCurrencies

# getMoonPayCurrencies

Fetches the list of crypto currencies supported by [MoonPay](https://www.moonpay.com/) for a given chain and network, filtered to active currencies only. Use this to build a token picker before generating a MoonPay onramp URL with [`getMoonPayUrl`](https://docs.dynamic.xyz/docs/javascript/funding/get-moonpay-url).

Requires a MoonPay onramp to be enabled and configured for your environment in the Dynamic Console.

## Usage

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

const currencies = await getMoonPayCurrencies({
  chain: "EVM",
  networkId: "1", // Ethereum mainnet
});

currencies.forEach((currency) => {
  console.log(currency.code, currency.name);
});
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `chain` | `Chain` | The blockchain to fetch supported currencies for (e.g., `'EVM'`, `'SOL'`). |
| `networkId` | `string` (optional) | The network ID to filter currencies by (e.g., `'1'` for Ethereum mainnet, `'137'` for Polygon). |
| `client` | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple clients. |

## Returns

`Promise<MoonPayCurrency[]>` - A promise that resolves to an array of supported MoonPay currencies. Returns an empty array if none are available.

```typescript theme={"system"}
type MoonPayCurrency = {
  code: string; // MoonPay currency code (e.g., 'usdc', 'eth')
  name: string; // Human-readable name (e.g., 'USD Coin')
  icon: string; // URL to the currency icon
};
```

## Examples

### React

```tsx theme={"system"}
import { useGetMoonPayCurrencies } from "@dynamic-labs-sdk/react-hooks";
import { getMoonPayUrl } from "@dynamic-labs-sdk/client";

function MoonPayTokenPicker({ walletAddress }) {
  const { data: currencies = [], isLoading } = useGetMoonPayCurrencies({
    chain: "EVM",
    networkId: "1",
  });

  const handleSelect = async (code: string) => {
    const url = await getMoonPayUrl({
      chain: "EVM",
      walletAddress,
      token: code,
      currency: "USD",
    });
    if (new URL(url).protocol === "https:") {
      window.open(url, "_blank");
    }
  };

  if (isLoading) return <p>Loading currencies...</p>;

  return (
    <ul>
      {currencies.map((currency) => (
        <li key={currency.code} onClick={() => handleSelect(currency.code)}>
          <img src={currency.icon} alt={currency.name} width={20} />
          {currency.name} ({currency.code.toUpperCase()})
        </li>
      ))}
    </ul>
  );
}
```

### Check if a token is supported

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

const isTokenSupported = async (code) => {
  const currencies = await getMoonPayCurrencies({ chain: "EVM" });

  return currencies.some(
    (currency) => currency.code.toLowerCase() === code.toLowerCase()
  );
};

const canBuyUsdc = await isTokenSupported("usdc");
```

## Errors

| Error | Description |
| - | - |
| `MoonPayCurrenciesFetchError` | The request to fetch supported MoonPay currencies failed. |

## Prerequisites

* MoonPay must be enabled and configured as an onramp provider for your environment in the Dynamic Console.

## Related functions

* [getMoonPayUrl](https://docs.dynamic.xyz/docs/javascript/funding/get-moonpay-url.md) - Get a signed MoonPay onramp URL for a wallet
* [getCoinbaseBuyUrl](https://docs.dynamic.xyz/docs/javascript/funding/get-coinbase-buy-url.md) - Get a Coinbase onramp buy URL


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