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.
You can get token balances across multiple chains and networks by calling the getMultichainBalances function.
This function fetches cryptocurrency and token balances for wallet addresses across different chains, networks and addresses specified in the request.
Usage
import { getMultichainBalances } from '@dynamic-labs-sdk/client';
const chainBalances = await getMultichainBalances({
balanceRequest: {
filterSpamTokens: true, // Optional: filter out spam tokens (default: true)
balanceRequests: [
{
address: "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0",
chain: "EVM",
networkIds: [1, 137, 56], // Ethereum, Polygon, BNB
whitelistedContracts: ["0x..."] // Optional: contracts to not filter out
},
{
address: "CKEAuq1E7hUcrjDcu1xP6nax3YBvEhhq7qaCzDUkPNer",
chain: "SOL",
networkIds: [101] // Solana mainnet
}
]
}
});
Parameters
| Parameter | Type | Description |
|---|
balanceRequest | MultichainAccountBalancesRequest | The balance request configuration |
MultichainAccountBalancesRequest
| Parameter | Type | Required | Description |
|---|
filterSpamTokens | Boolean | No | Filter out spam tokens (default: true) |
balanceRequests | Array | Yes | Array of balance request objects |
Balance Request Object
| Parameter | Type | Required | Description |
|---|
address | String | Yes | The wallet address |
chain | ChainEnum | Yes | Chain type (EVM, SOL, BTC, etc.) |
networkIds | Array<Number> | Yes | Array of network IDs to query |
whitelistedContracts | Array<String> | No | Contract addresses to not filter out |
React
Fetch multichain balances in a useEffect:
import { getMultichainBalances } from '@dynamic-labs-sdk/client';
import { useEffect, useState } from 'react';
function MultichainBalances({ evmAddress, solanaAddress }) {
const [chainBalances, setChainBalances] = useState([]);
useEffect(() => {
if (!evmAddress) return;
getMultichainBalances({
balanceRequest: {
filterSpamTokens: true,
balanceRequests: [
{ address: evmAddress, chain: 'EVM', networkIds: [1, 137] },
...(solanaAddress ? [{ address: solanaAddress, chain: 'SOL', networkIds: [101] }] : []),
],
},
}).then(setChainBalances);
}, [evmAddress, solanaAddress]);
return <pre>{JSON.stringify(chainBalances, null, 2)}</pre>;
}
Response
The function returns a Promise that resolves to chainBalances - an array of chain balance objects organized by chain and network.