getMoonPayCurrencies
Fetches the list of crypto currencies supported by MoonPay 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.
Requires a MoonPay onramp to be enabled and configured for your environment in the Dynamic dashboard.
Usage
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.
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
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
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 dashboard.
Last modified on June 29, 2026