Indexing ERC20 Token Transfers on Base
Introduction
In this tutorial, you'll learn how to index ERC20 token transfers on the Base network using Envio HyperIndex. By leveraging the no-code contract import feature, you'll be able to quickly analyze USDC transfer activity, including identifying the largest transfers.
We'll create an indexer that tracks all USDC token transfers on Base by extracting the Transfer events emitted by the USDC contract. The entire process takes less than 5 minutes to set up and start querying data.
Prerequisites
Before starting, ensure you have the following installed:
- Node.js (v22 or newer recommended)
- pnpm (v8 or newer)
- Docker Desktop (required to run the Envio indexer locally)
Note: Docker is specifically required to run your blockchain indexer locally. You can skip Docker installation if you plan only to use Envio Cloud.
Step 1: Initialize Your Indexer
- Open your terminal in an empty directory and run:
pnpx envio init
- Name your indexer (we'll use "usdc-base-transfer-indexer" in this example):
- Choose your preferred language (TypeScript, JavaScript, or ReScript):
Step 2: Import the USDC Token Contract
-
Select Contract Import → Block Explorer → Base
-
Enter the USDC token contract address on Base:
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 -
Select the
Transferevent:- Navigate using arrow keys (↑↓)
- Press spacebar to select the event
Tip: You can select multiple events to index simultaneously if needed.
- When finished adding contracts, select I'm finished
Step 3: Start Your Indexer
- If you have any running indexers, stop them first:
pnpm envio stop
Note: You can skip this step if this is your first time running an indexer.
- Start your new indexer:
pnpm dev
This command:
- Starts the required Docker containers
- Sets up your database
- Launches the indexing process
- Opens the Hasura GraphQL interface
Step 4: Understanding the Generated Code
Let's examine the key files that Envio generated:
1. config.yaml
This configuration file defines:
- Network to index (Base)
- Starting block for indexing
- Contract address and ABI details
- Events to track (Transfer)