Skip to content

satyam455/solana-indexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solana Transaction Indexer

A real-time Solana blockchain transaction indexer built in Rust. It connects to Solana mainnet via WebSocket, parses and stores transactions in PostgreSQL, and serves a REST API, WebSocket feed, and Prometheus metrics endpoint.

Architecture

Solana mainnet (WebSocket)
        |
        v
  Ingestion layer     <- logsSubscribe, auto-reconnect with exponential backoff
        | tokio::mpsc
        v
  Parser              <- extracts signature, slot, programs, token transfers
        |
        +--> PostgreSQL   <- batch inserts, ON CONFLICT DO NOTHING
        |
        +--> broadcast::channel -> WebSocket clients (live feed)

  axum HTTP server    <- REST API + WebSocket endpoint + Prometheus metrics

Stack

  • Rust + Tokio
  • sqlx
  • axum
  • Prometheus

Quick Start

sudo service postgresql start
createdb solana_indexer

export DATABASE_URL=postgres://postgres:postgres@localhost:5432/solana_indexer
sqlx migrate run

cargo run

API Endpoints

Method Endpoint Description
GET /health Health check + indexed count
GET /metrics Prometheus metrics
GET /api/stats Transaction + transfer counts
GET /api/transactions?limit=20 Recent transactions
GET /api/transactions/:signature Single transaction
GET /api/transactions/program/:program_id By program
GET /api/token-transfers/:mint Token transfers by mint
WS /ws Live transaction stream

Testing

export DATABASE_URL=postgres://postgres:postgres@localhost:5432/solana_indexer
cargo test

Example Queries

curl "http://localhost:3000/api/transactions/program/JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4?limit=10"
curl "http://localhost:3000/api/token-transfers/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v?limit=10"
websocat ws://localhost:3000/ws
curl http://localhost:3000/metrics

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages