Solana - Error "Too many accounts requested, limit is 10,000,000"

Tatum's token balance endpoint can't read Solana tokens whose program owns over 10 million accounts; use the getTokenAccountsByOwner RPC method instead.

The Solana error Too many accounts requested, limit is 10,000,000 comes from Tatum's token balance endpoint when the token program behind the token owns more than 10 million accounts. The endpoint has no workaround for this limit. Get the balance with the Solana RPC method getTokenAccountsByOwner instead, filtered by the token's mint address.

Symptom

When you use Tatum's API to retrieve the token balance of a Solana address, you get the following error:

{
  "statusCode": 403,
  "errorCode": "erc20.get.error",
  "message": "Get operation failed",
  "cause": "failed to get accounts owned by program ####: Too many accounts requested, limit is 10,000,000",
  "dashboardLog": "https://dashboard.tatum.io/logs?id=####"
}

Cause

This error occurs because the endpoint has a default limitation on the number of accounts that can be requested in a single operation.

The error arises when the number of accounts owned by a token program exceeds the threshold of 10 million accounts.

Solution

At present, there are no workarounds for this limitation via the Tatum token balance endpoint. Use the Solana RPC instead:

  1. Call getTokenAccountsByOwner with the wallet address and a filter with the token's mint. This example gets the USDC balance of a wallet:

    curl --location 'https://solana-mainnet.gateway.tatum.io' \
      --header 'Content-Type: application/json' \
      --header 'x-api-key: {YOUR_API_KEY}' \
      --data '{
        "jsonrpc": "2.0",
        "id": 1,
        "method": "getTokenAccountsByOwner",
        "params": [
          "HMKa355WmAEPDMakaWrS47goUiggsonDiLH8kicck6pL",
          { "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
          { "encoding": "jsonParsed" }
        ]
      }'
  2. Read the balance from account.data.parsed.info.tokenAmount of each returned token account. amount is the raw integer, decimals the token's decimals and uiAmountString the balance in whole tokens (response trimmed):

    {
      "jsonrpc": "2.0",
      "result": {
        "context": { "slot": 474516414 },
        "value": [
          {
            "pubkey": "JAneVaFUCJksJ3r9LUDuEHLdAT5zJh5KAZogn4mWir7r",
            "account": {
              "data": {
                "program": "spl-token",
                "parsed": {
                  "info": {
                    "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
                    "owner": "HMKa355WmAEPDMakaWrS47goUiggsonDiLH8kicck6pL",
                    "tokenAmount": {
                      "amount": "45218138",
                      "decimals": 6,
                      "uiAmount": 45.218138,
                      "uiAmountString": "45.218138"
                    }
                  },
                  "type": "account"
                }
              }
            }
          }
        ]
      },
      "id": 1
    }
  3. Add up the amounts if value lists more than one token account for the mint.

  4. To list every token of the wallet, replace the mint filter with { "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }, the SPL Token program.

Find the Tatum Solana RPC endpoints and methods on Solana RPC.

📘

Note

Find the official Solana documentation for the getTokenAccountsByOwner RPC method in the Solana docs.

FAQ

How do I get the balance of a single token account?

If you already know the token account address, call getTokenAccountBalance with it. It returns the balance of that one SPL Token account.

Can I use getProgramAccounts instead?

It isn't a reliable option for SPL tokens. getProgramAccounts scans every account the program owns, and RPC nodes can exclude programs with many accounts, such as Tokenkeg..., from it. See getProgramAccounts performance.

Still stuck?

Report the issue to support with the wallet address, the token mint and the dashboardLog ID from the error.


Did this page help you?