Get the Token Balance of an Address (ERC-20 or compatible)

Check ERC-20 token balances with the Tatum Data API for all tokens of an address, the v3 endpoint for one token contract, or balanceOf() over RPC.

To check the ERC-20 token balance of an address, call a Tatum REST endpoint instead of querying each token contract yourself. The Data API Get wallet portfolio endpoint with tokenTypes=fungible returns every fungible token the address holds, and the v3 token balance endpoint returns the balance of one token contract. BEP-20 and other compatible tokens work the same way.

You can retrieve the Token balance (ERC-20, BEP-20 or compatible) of an address via the following methods:

Request Example:

curl --location 'https://api.tatum.io/v4/data/wallet/portfolio?chain=ethereum-mainnet&addresses=0xae680ed83baf08a8028118bd19859f8a0e744cc6&tokenTypes=fungible&pageSize=50&offset=0' \
--header 'x-api-key: {YOUR_API_KEY}'
{
    "result": [
        {
            "chain": "ethereum-mainnet",
            "address": "0xae680ed83baf08a8028118bd19859f8a0e744cc6",
            "balance": "283.333333333333333333",
            "denominatedBalance": "283333333333333333333",
            "decimals": 18,
            "tokenAddress": "0x45dd18c5e0fa701abff449f6542aa53e258710b4",
            "type": "fungible"
        },
        {
            "chain": "ethereum-mainnet",
            "address": "0xae680ed83baf08a8028118bd19859f8a0e744cc6",
            "balance": "8.69",
            "denominatedBalance": "8690000000000000000",
            "decimals": 18,
            "tokenAddress": "0x090f21a84a0e9674c1828aca1db69ec8ae1454e8",
            "type": "fungible"
        }
    ],
    "prevPage": "",
    "nextPage": ""
}

Good to Know

  • Tatum endpoints provide token balances from "finalized" blocks.
  • Tatum endpoints return values at an average of 20 blocks behind the tip.
  • If you need immediate token balance, irregardless of a finalized block, use the RPC balanceOf().
  • On Solana, the v3 token balance endpoint fails for tokens whose program owns more than 10 million accounts; see Solana "Too many accounts requested" error and fix.

FAQ

Can I get all token balances of an address in one call?

Yes. The Data API Get wallet portfolio endpoint with tokenTypes=fungible returns the fungible token balances of one address per request, paginated with pageSize and offset.

Why is the API balance behind my wallet?

Tatum endpoints return token balances from finalized blocks, on average about 20 blocks behind the chain tip. For the latest balance, call the token contract's balanceOf() over RPC.

How do I get a token balance with an RPC call?

Send an eth_call to the token contract with the balanceOf(address) selector 0x70a08231 followed by the wallet address padded to 32 bytes. See Get the token balance of an address via RPC for a full example.

Is the balance in token units or the smallest unit?

The v3 endpoint returns the balance in the token's smallest unit, so divide it by 10 to the power of the token's decimals. The wallet portfolio endpoint returns balance in token units, plus denominatedBalance in the smallest unit and decimals; see Token decimals.

Does this work for BEP-20 tokens?

Yes. Both endpoints support ERC-20-compatible tokens such as BEP-20 on BNB Smart Chain, and each API Reference page lists its supported chains.


Did this page help you?