High-performance SQL indexer for EVM-compatible blockchains
A production-ready indexer that fetches and stores blockchain data for later analysis. Optimized for performance with support for parallel block processing, dynamic RPC capability detection, and efficient memory usage.
- ✅ Complete blockchain primitives: blocks, transactions, receipts, logs, traces, withdrawals
- ✅ Token transfers: ERC20, ERC721, ERC1155
- ✅ DEX trades: Uniswap V2/V3, Curve, Balancer, and multiple high-volume AMMs
- ✅ DEX pairs: Track pair/pool creation across all supported DEXes
- ✅ Liquidity tracking: Monitor liquidity additions, removals, and reserve updates
- ✅ Contract tracking: Automatically indexes deployed contracts
- ✅ Parallel processing: Configurable batch size for optimal throughput
- ✅ Smart RPC usage: Auto-detects
eth_getBlockReceiptssupport
- Rust 1.70+
- ClickHouse 23.0+
- Clone the repository:
git clone https://github.com/eabz/evm-indexer && cd evm-indexer- Start the services:
docker-compose up -dThis will start:
- ClickHouse database on ports 8123 (HTTP) and 9000 (native)
- Indexer configured for Ethereum mainnet
- Monitor logs:
docker-compose logs -f indexer- Clone the repository:
git clone https://github.com/eabz/evm-indexer && cd evm-indexer- Build the program:
cargo build --release- Run the indexer:
./target/release/indexer \
--chain 1 \
--database clickhouse://user:password@localhost:8123/indexer \
--rpcs https://eth.llamarpc.com \
--start-block 0 \
--batch-size 100| Flag | Default | Description |
|---|---|---|
--chain |
1 |
Chain ID to index (1=Ethereum, 56=BSC, 137=Polygon, etc.) |
--database |
required | ClickHouse connection string: clickhouse://user:pass@host:port/db |
--rpcs |
required | Comma-separated list of RPC endpoints |
--start-block |
0 |
Block number to start syncing from |
--end-block |
0 |
Last block to sync (0 = continuous sync) |
--batch-size |
200 |
Number of blocks to fetch in parallel |
--ws |
"" |
WebSocket endpoint for real-time block updates |
--traces |
true |
Fetch transaction traces (requires archive node) |
--fetch-uncles |
false |
Fetch uncle blocks (adds 5-10% RPC calls) |
--new-blocks-only |
false |
Only index new blocks (skip historical sync) |
--debug |
false |
Enable debug logging |
Create a .env file (see .env.example):
# ClickHouse Configuration
CLICKHOUSE_DB=indexer
CLICKHOUSE_USER=indexer
CLICKHOUSE_PASSWORD=indexer
# Indexer Configuration
CHAIN_ID=1
START_BLOCK=0
BATCH_SIZE=10
RPC_URL=https://eth.llamarpc.com
DEBUG=true
FETCH_UNCLES=false
TRACES=trueThe indexer creates the following tables in ClickHouse:
blocks- Block headers and metadatatransactions- Transaction data with gas infologs- Event logs emitted by contractstraces- Internal transaction tracescontracts- Deployed contract addresseswithdrawals- Validator withdrawals (post-merge)erc20_transfers- ERC20 token transferserc721_transfers- NFT transferserc1155_transfers- Multi-token transfersdex_trades- DEX swap transactionsdex_pairs- DEX pair/pool creation eventsdex_liquidity_updates- Liquidity additions, removals, and sync events
See migrations/create_tables.sql for full schema.
- Small batches (10-50): Lower memory, slower throughput
- Medium batches (100-200): Balanced (recommended)
- Large batches (500+): Higher memory, faster throughput
- Use multiple RPCs for better reliability
- Archive nodes required for traces
eth_getBlockReceiptssupport = 2x faster
- Use SSD storage for better performance
- Increase
max_insert_block_sizefor large batches - Enable compression for storage savings
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details
- GitHub Issues: Report bugs
- Discussions: Ask questions