Go chain indexer for Roburna testnet (Phase 1).
cd chain-indexer
docker-compose up -dThis will start:
- PostgreSQL database
- Redis cache
- The indexer service
# Build
cd chain-indexer
go mod tidy
CGO_ENABLED=0 go build -o bin/indexer ./cmd/indexer
# Run with environment variables
RPC_URL=https://preseed-testnet-1.roburna.com/ DB_URL=postgresql://postgres:postgres@localhost:5432/chainscope ./bin/indexer.\run-supabase.bat| Variable | Required | Default | Description |
|---|---|---|---|
RPC_URL |
Yes | - | EVM chain RPC endpoint |
DB_URL |
Yes | - | PostgreSQL connection string |
REDIS_URL |
No | redis://localhost:6379 | Redis connection string |
CHAIN_ID |
No | auto-detect | Override chain ID |
START_BLOCK |
No | 0 | Starting block for backfill |
BATCH_SIZE |
No | 100 | Blocks per batch |
WORKERS |
No | 4 | Concurrent workers |
Create config.yaml for defaults:
rpc_url: https://preseed-testnet-1.roburna.com/
chain_id: 159
db_url: postgres://postgres:postgres@localhost:5432/chainscope
redis_url: redis://localhost:6379
start_block: 0
batch_size: 100
workers: 4Environment variables override config file values.
- PostgreSQL 16+ (or Docker)
- Redis 7+ (or Docker)
- Go 1.22+
# View live logs
docker-compose logs -f indexer
# Check service status
docker-compose ps
# View database data
docker exec -it chain-indexer-postgres-1 psql -U postgres -d chainscope
# Stop the system
docker-compose down
# Restart services
docker-compose restartThe indexer creates the following tables:
blocks- Block headers and metadatatransactions- Transaction detailslogs- Event logs from smart contractssync_state- Indexer synchronization state
If you see connection errors, ensure PostgreSQL is running:
# Check if containers are running
docker-compose ps
# Restart database
docker-compose restart postgresIf you encounter "value too long" errors, the database schema may need updates:
# Stop indexer
docker-compose stop indexer
# Update schema (if needed)
docker exec -i chain-indexer-postgres-1 psql -U postgres -d chainscope -c "
ALTER TABLE transactions ALTER COLUMN value TYPE TEXT;
ALTER TABLE transactions ALTER COLUMN gas_price TYPE TEXT;
ALTER TABLE transactions ALTER COLUMN gas_fee_cap TYPE TEXT;
ALTER TABLE transactions ALTER COLUMN gas_tip_cap TYPE TEXT;
ALTER TABLE transactions ALTER COLUMN r TYPE TEXT;
ALTER TABLE transactions ALTER COLUMN s TYPE TEXT;
"
# Restart indexer
docker-compose up -d indexerFor better performance:
- Increase
BATCH_SIZEfor faster backfill - Increase
WORKERSfor parallel processing - Use SSD storage for PostgreSQL
- Tune PostgreSQL configuration for your hardware