A production-style backend service that indexes ERC-20 Transfer events from Ethereum-compatible networks and exposes analytics APIs such as volume, daily activity, and top addresses.
This project is designed as an open-source starter and portfolio-grade example of how to build a real-time blockchain indexer with clean analytics.
-
✅ Real-time ERC-20
Transferevent indexing -
✅ Safe, idempotent event storage (txHash + logIndex)
-
✅ Token decimal–aware volume normalization
-
✅ Analytics APIs:
- Total transfer count
- Total transferred volume
- Daily transfer volume
- Daily transfer count
- Top senders
- Top receivers
-
✅ Clean, frontend-ready API responses
Ethereum RPC
│
▼
Ethers.js Listener
│
▼
Indexer Service
│
▼
Prisma ORM
│
▼
PostgreSQL / SQLite
│
▼
Analytics Service
│
▼
REST API (Express)
- On-chain → Off-chain data modeling
- Decimals normalized at query-time, not stored incorrectly
- Analytics computed from indexed events, not raw logs
- Node.js + TypeScript
- Express
- Ethers.js
- Prisma ORM
- PostgreSQL / SQLite
- Decimal.js (safe math)
npm installCreate .env:
DATABASE_URL="file:./dev.db"
RPC_URL="https://your-rpc-url"
CONTRACT_ADDRESS="0xYourERC20Contract"npx prisma migrate devnpm run devServer runs at:
http://localhost:3000
GET /analytics/transfers/:contractId
{
"contractId": 1,
"stats": {
"transferCount": 29,
"totalVolume": "1325.90"
},
"dailyVolume": [
{ "date": "2026-01-12", "volume": "1325.80" }
],
"dailyCount": [
{ "date": "2026-01-12", "count": 28 }
],
"topSenders": [
{ "address": "0x...", "value": "662.40" }
],
"topReceivers": [
{ "address": "0x...", "value": "662.40" }
]
}-
The blockchain listener subscribes to
Transferevents -
Each log is parsed and validated
-
Events are stored with:
txHashlogIndex
-
This ensures no duplicates even across restarts
- Add event ABI to the contract interface
- Subscribe in
listener.ts - Parse event arguments
- Store in
eventtable - Add analytics logic if needed
This architecture supports any event type, not just ERC-20.
- Historical backfill using
getLogs - Multiple contracts support
- WebSocket streaming API
- Frontend dashboard
This repository demonstrates:
- Real blockchain indexing
- Correct financial math
- Backend analytics design
- Production-safe data handling
Ideal for:
- Web3 backend roles
- Open-source contributions
- Interview discussions
MIT