> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moralis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Get ERC20 Token Balances for a Wallet

> Learn how to fetch all ERC20 token balances for any wallet address using the Moralis API.

## Introduction

In this tutorial, you'll learn how to retrieve all ERC20 token balances for a wallet address using the Moralis API. This is essential for building portfolio trackers, wallet dashboards, or any application that needs to display a user's token holdings. We'll use the following Moralis API endpoint:

* [Get Wallet Token Balances](/data-api/evm/wallet/token-balances) - Fetch all ERC20 tokens held by a wallet

## Prerequisites

* Node.js v18+ installed
* A Moralis API key ([get one free](https://admin.moralis.io))

## Step 1: Set Up Your Project

Create a new directory for your project and initialize it:

```bash theme={null}
mkdir get-token-balances && cd get-token-balances
npm init -y
```

## Step 2: Create the Script

Create a file called `index.js` and add the following code:

```javascript theme={null}
// index.js
const API_KEY = 'YOUR_API_KEY';
const WALLET_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; // Vitalik's wallet

async function getTokenBalances() {
  const response = await fetch(
    `https://deep-index.moralis.io/api/v2.2/wallets/${WALLET_ADDRESS}/tokens?chain=eth`,
    {
      headers: {
        'X-API-Key': API_KEY,
      },
    }
  );

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

getTokenBalances();
```

Replace `YOUR_API_KEY` with your actual Moralis API key.

## Step 3: Run the Script

Execute the script to fetch the token balances:

```bash theme={null}
node index.js
```

## Example Response

```json theme={null}
{
  "result": [
    {
      "token_address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "symbol": "USDC",
      "name": "USD Coin",
      "logo": "https://cdn.moralis.io/eth/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.png",
      "thumbnail": "https://cdn.moralis.io/eth/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_thumb.png",
      "decimals": 6,
      "balance": "1000000000",
      "possible_spam": false,
      "verified_contract": true,
      "balance_formatted": "1000",
      "usd_price": 0.999,
      "usd_price_24hr_percent_change": 0.01,
      "usd_value": 999.0,
      "portfolio_percentage": 25.5
    }
  ]
}
```

## Understanding the Response

| Field                  | Description                                    |
| ---------------------- | ---------------------------------------------- |
| `token_address`        | The contract address of the ERC20 token        |
| `symbol`               | The token's ticker symbol (e.g., USDC)         |
| `name`                 | The full name of the token                     |
| `decimals`             | Number of decimal places the token uses        |
| `balance`              | Raw token balance (in smallest unit)           |
| `balance_formatted`    | Human-readable balance with decimals applied   |
| `usd_price`            | Current USD price of the token                 |
| `usd_value`            | Total USD value of the token balance           |
| `possible_spam`        | Whether the token is flagged as potential spam |
| `verified_contract`    | Whether the token contract is verified         |
| `portfolio_percentage` | Percentage this token represents in the wallet |

## Next Steps

* [Get Token Metadata](/get-started/tutorials/data-api/tokens-and-markets/get-erc-20-token-metadata-by-address-or-symbol) - Learn how to get detailed token information
* [Get Token Price](/get-started/tutorials/data-api/prices-and-charts/get-the-price-of-an-erc-20-token) - Fetch current token prices
* [API Reference](/data-api/evm/wallet/token-balances) - Full API documentation

***

## Fetch Wallet Data

<iframe src="https://www.youtube.com/embed/DnfTx7hgD_E" title="Fetch Wallet Data" width="100%" height="400" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />
