This project indexes ERC20 token transfers on the Blast network and provides an API to query transfer history for specific addresses. It's built using TypeScript, Express.js, Prisma ORM, and Viem for blockchain interaction.
- Docker for containerization
- PostgreSQL for data storage
- Prisma ORM for data interaction and database schema setup
- Express.js as the Node.js framework
- TypeScript for type-safe development
- Viem for blockchain interaction
- Indexes all transfers of a specified ERC20 token (default: Blast Wrapped Ether) since inception
- Provides a public HTTP API to query transfer history for a given address
- Configurable via environment variables to support different EVM networks and tokens
- Implements pagination for API responses
- Validates Ethereum addresses
- Docker and Docker Compose
- Node.js (v18 or later)
- Yarn
- Clone the repository:
git clone https://github.com/HalukG/web3-token-indexer-backend.git
- Modify the
.env
file in the root directory based on token requirements
- Build and start the containers:
docker compose up --build
- The application will start indexing transfers and the API will be available at
http://localhost:3000
.
Access Prisma Studio at http://localhost:5555
when the Docker containers are running.
The following environment variables can be configured in the .env
file:
PORT
: The port on which the API server will runRPC_ENDPOINT
: The RPC endpoint for the blockchainTOKEN_ADDRESS
: The address of the ERC20 token to indexCHAIN_ID
: The chain ID of the networkDB_USER
: PostgreSQL database userDB_PASSWORD
: PostgreSQL database passwordDB_NAME
: PostgreSQL database name
- Query transfer history for a specific address:
GET /api/transfers/:address
Replace :address
with the Ethereum address you want to query.
Example using curl:
curl -X GET "http://localhost:3000/api/transfers/0x1234567890123456789012345678901234567890"
- The API supports pagination with
page
andlimit
query parameters:
curl -X GET "http://localhost:3000/api/transfers/0x1234567890123456789012345678901234567890?page=1&limit=10"
- Monitor indexing progress:
docker-compose logs -f app
- Monitor indexing progress:
curl -X GET "http://localhost:3000/api/transfers/0x4300000000000000000000000000000000000004?page=1&limit=10"
- Test with an invalid address:
curl -X GET "http://localhost:3000/api/transfers/invalidaddress"
- Access Prisma Studio at
http://localhost:5555
to view indexed data.
Given more time, the following improvements could be made:
- Implement an event-based architecture using message queues (e.g., RabbitMQ, Kafka) to decouple the indexer from the API service.
- Add filtering options for inbound/outbound transactions.
- Implement rate limiting and caching to improve API performance.
- Add support for indexing multiple tokens simultaneously.
- Implement a more robust error handling and retry mechanism.
- Add unit and integration tests.
- Containerization with Docker
- Use of specified tech stack (PostgreSQL, Prisma, Express.js, TypeScript, Viem)
- Indexing of token transfers since inception
- Public HTTP API for querying transfer history
This project is licensed under the MIT License