Summary

Used to fetch the token balances of an account on a specified network. The default behavior is to return the token balances of the primary account on the current network, but optionally the account, network, includeFiat and includeNativeBalance can be specified. Chain support includes 67 EVM networks, Solana Mainnet and testnet, Eclipse Mainnet and Bitcoin Ruins. EVM networks include:
NameChain ID
abstract2741
ancient8888888888
ape_chain33139
arbitrum42161
arbitrum_nova42170
avalanche_c43114
avalanche_fuji43113
b38333
base8453
base_sepolia84532
berachain80094
blast81457
bnb56
bob60808
boba288
celo42220
corn21000000
cyber7560
degen666666666
ethereum1
fantom250
flare14
forma984122
fraxtal252
funkichain33979
gnosis100
ham5112
hychain2911
hyper_evm999
ink57073
interop_alpha_0420120000
interop_alpha_1420120001
kaia8217
katana747474
linea59144
lisk1135
mantle5000
metis1088
mint185
mode34443
monad_testnet10143
omni166
opbnb204
optimism10
polygon137
proof_of_play70700
proof_of_play_boss70701
rari1380012617
redstone690
ronin2020
scroll534352
sei1329
sepolia11155111
shape360
soneium1868
sonic146
superposition55244
superseed5330
swellchain1923
unichain130
wemix1111
world480
xai660279
zero_network543210
zkevm1101
zksync324
zora7777777
This will return all tokens with at least 50,000 USD in liquidity

Usage

import { useTokenBalances } from "@dynamic-labs/sdk-react-core";

const { tokenBalances, isLoading, isError, error } = useTokenBalances();
// tokenBalances
[
  {
    "networkId": 1,
    "address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0",
    "name": "Polygon",
    "symbol": "MATIC",
    "decimals": 18,
    "logoURI": "https://assets.coingecko.com/coins/images/4713/thumb/polygon.png?1698233745",
    "balance": 0.7851804304793578,
    "rawBalance": 785180430479357800,
    "price": 0.703229,
    "marketValue": 0.5521616489455683
  },
  {
    "networkId": 1,
    "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "name": "USDC",
    "symbol": "USDC",
    "decimals": 6,
    "logoURI": "https://assets.coingecko.com/coins/images/6319/thumb/usdc.png?1696506694",
    "balance": 50,
    "rawBalance": 50000000,
    "price": 1,
    "marketValue": 50
  }
]

With arguments

ParameterTypeDescription
networkIdNumberThe network ID
chainNameChainEnumThe chain used
tokenAddressesString[]The token addresses
includeFiatBooleanShould include Fiat prices
includeNativeBalanceBooleanShould include native balance
Optionally, you can pass an object with the account address and network id specified. Additionally, you can pass an array of token addresses to filter the results.
import { useTokenBalances } from "@dynamic-labs/sdk-react-core";

const { tokenBalances, isLoading, isError, error } = useTokenBalances({
  networkId: 1,
  accountAddress: "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0",
  includeFiat: true,
  includeNativeBalance: true,
});

return (
  <ul>
    {tokenBalances?.map((tokenBalance) => (
      <li key={tokenBalance.address}>
        {tokenBalance.name} {tokenBalance.balance} {tokenBalance.symbol} ($
        {tokenBalance.price}) | ${tokenBalance.marketValue}
      </li>
    ))}
  </ul>
);
// with token addresses filter
import { useTokenBalances } from "@dynamic-labs/sdk-react-core";

const { tokenBalances, isLoading, isError, error } = useTokenBalances({
  networkId: 1,
  accountAddress: "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0",
  tokenAddresses: ["0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0"],
});
Solana support with Fiat prices (with SDK version 2.2.9)
import { useTokenBalances } from "@dynamic-labs/sdk-react-core";
import { ChainEnum } from "@dynamic-labs/sdk-api";

const { tokenBalances, isLoading, isError, error } = useTokenBalances({
  chainName: ChainEnum.Sol,
  accountAddress: address,
  includeFiat: true,
  includeNativeBalance: true,
});