Skip to main content

Overview

The CDP SDK allows you to retrieve token balances of an address using the listTokenBalances method for Base. For Solana token balances, use the REST API directly. Additional information can be found in our SDK Reference. In this guide, you will learn how to retrieve ERC-20 and native gas token balances of an address on Base networks.

Prerequisites

Configure

1

Install dependencies

2

Create an .env file

Create a .env file in your project root:
3

Add API credentials

If you downloaded your CDP API key as a JSON file, it will look like this. Otherwise, you can copy the values directly from the CDP Portal:
Copy these values into your .env file:

Example

In the example below, we query token balances for a known exchange address on Base mainnet.
After running the snippet above, you should see the following output:
This output shows:
  • Token balances: Each ERC-20 token with its amount and contract address
  • Contract addresses: The long hex strings identify each specific token contract on Base mainnet
  • Large holdings: This exchange wallet holds millions of various tokens

Sample response

The token balance response provides detailed token information:

Response fields

Pagination

listTokenBalances supports paginated responses for addresses with many balances: