Skip to content
tyu1996Public

About

Solana Program Activity Indexer

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Solana Program Activity Indexer

A small Rust backend service that indexes on-chain activity for a configurable set of Solana program IDs and exposes it through a JSON HTTP API and a minimal dashboard.

What It Does

  • Polls the Solana JSON-RPC for new signatures involving each tracked program, using each program's last-seen signature as a cursor so only new activity is fetched.
  • Fetches the full transaction payload for every new signature and stores normalized metadata plus the raw JSON in PostgreSQL.
  • Ingestion is idempotent — re-running against the same signatures is safe (ON CONFLICT upserts and a (program_id, signature) join table).
  • Records ingestion errors in a separate table instead of crashing the worker, so a bad signature never blocks the rest of the batch.
  • Exposes /health, /programs, /programs/:id/transactions, and /transactions/:signature over HTTP.

Architecture

            ┌──────────────────────┐
            │  Solana RPC          │
            └──────────┬───────────┘
                       │  signatures + raw tx
                       ▼
       ┌───────────────────────────────┐
       │ IndexerWorker (tokio task)    │
       │  - cursor per program         │
       │  - per-signature retries      │
       └──────────┬────────────────────┘
                  │
                  ▼
       ┌───────────────────────────────┐
       │ PostgreSQL                    │
       │  tracked_programs             │
       │  transactions (raw_jsonb)     │
       │  program_transactions         │
       │  ingestion_errors             │
       └──────────┬────────────────────┘
                  │
                  ▼
       ┌───────────────────────────────┐
       │ Axum HTTP API + static UI     │
       └───────────────────────────────┘

The RPC layer is a SolanaRpc trait, so the worker and parser are exercised in tests without touching the network.

Local Development

cp .env.example .env
docker compose up -d postgres
cargo run

Migrations are embedded and run on startup. The dashboard is served from static/ at http://localhost:8080/.

Example Requests

curl http://localhost:8080/health

curl -X POST http://localhost:8080/programs \
  -H 'content-type: application/json' \
  -d '{"program_id":"MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr","label":"Memo Program"}'

curl http://localhost:8080/programs/MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr/transactions

Tests

Unit tests run with cargo test. The database integration tests use sqlx::test and need a running Postgres:

docker compose up -d postgres
DATABASE_URL=postgres://postgres:postgres@localhost:5432/solana_indexer cargo test

Stack

Rust 2021 · Tokio · Axum · sqlx · PostgreSQL · solana-client / solana-sdk · tracing.

About

Solana Program Activity Indexer

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages