← All Projects
INTERMEDIATE⚙ Go Backend3-4hMilan

Swap Event Indexer

Build a Go service that listens for Uniswap V3 Swap events on Gnosis Chain, decodes them, and stores them in a PostgreSQL database. Exposes a REST API for querying swap history with filtering and pagination.

Tech Stack

Gogo-ethereum (ethclient)PostgreSQLsqlx or pgxchi router

What You'll Learn

  • →Ethereum event log subscription and filtering
  • →ABI decoding of indexed and non-indexed event parameters
  • →Block reorganization handling
  • →Database schema design for blockchain events
  • →Pagination patterns for REST APIs

Milestones (0/4)

M1Event listener & ABI decoding
▾
M2PostgreSQL storage layer
▾
M3REST API with pagination
▾
M4Reorg handling & graceful shutdown
▾

Architecture Hints

Architecture
Gnosis Chain RPC
    │
    ▼
┌─────────────┐     ┌──────────────┐
│  Poller     │────▶│  Decoder     │
│  (blocks)   │     │  (ABI→struct)│
└─────────────┘     └──────┬───────┘
                           │
                    ┌──────▼───────┐
                    │  Repository  │
                    │  (batch ins) │
                    └──────┬───────┘
                           │
                    ┌──────▼───────┐
                    │  PostgreSQL  │
                    └──────┬───────┘
                           │
                    ┌──────▼───────┐
                    │  REST API    │
                    │  (chi)       │
                    └──────────────┘
Key design decisions: - Polling over WebSocket subscriptions (more reliable for production) - Batch inserts with idempotent upserts (handle reorgs gracefully) - Cursor-based pagination (more efficient than offset for large datasets) - Checkpoint stored in DB alongside events (atomic consistency)

Interview Talking Points