Indexing Basics
8 examples to get you started with Solana indexing - 5 basic and 3 intermediate.
Prerequisites
- RPC provider or self-hosted node for backfill
- Database (Postgres common) for persisted index state
- Understanding of Core RPC Methods
Basic Examples
1. Why RPC Alone Breaks at Scale
Wallet history via getSignaturesForAddress paginates thousands of HTTP calls.
# Slow for whales - each page is one RPC round trip
solana confirm -v $(solana transaction-history <PUBKEY> 2>/dev/null | head -1) 2>/dev/null || true- RPC is request/response - no durable query layer for SQL analytics.
- Rate limits cap historical backfills during product launch.
- Indexers write once, query many from your database.
Related: Pagination & Efficiency - RPC limits
2. Indexer Data Flow
Ingest, parse, store, serve.
Validator → Geyser/Yellowstone/Webhook → Parser → Postgres → API
- Ingestion is append-only slot-ordered events.
- Parser maps instructions to domain rows (swaps, votes, mints).
- API serves paginated queries to apps.
Related: Building an Indexer - implementation
3. Backfill vs Live Stream
Historical catch-up then tail new slots.
# Conceptual: replay slots 250000000..latest from archived ledger or RPC- Backfill uses
getBlock/getTransactionor provider archives. - Live stream uses Geyser or WebSocket after cursor catches tip.
- Store last processed slot for crash recovery.
4. Idempotent Writes
Use natural keys so replays do not duplicate rows.
INSERT INTO transfers (signature, idx, amount)
VALUES ($1, $2, $3)
ON CONFLICT (signature, idx) DO NOTHING;- Transactions have unique signatures; instruction index disambiguates inner ix.
- Reorgs are rare at
confirmedbut design for slot rollback flags on critical finance. - Replay from slot N after outage must be safe.
5. Parse with IDL
Decode instruction data deterministically.
// Concept: use generated client or anchor discriminator match
// if data[..8] == DEPOSIT_DISCRIMINATOR { ... }- Anchor IDL discriminators identify instruction variants.
- Codama-generated parsers keep schema in sync with program releases.
- Never key business logic on log string parsing alone.
Related: Parsing Program Data - decode detail
Intermediate Examples
6. Geyser Plugin Hook
Validator streams account/tx updates to your sink.
# Validator flag (operator setup)
agave-validator --geyser-plugin-config geyser.json- Plugins receive firehose at validator speed.
- You filter to programs you care about early to save CPU.
- See Geyser Plugins.
7. Yellowstone gRPC Consumer
High-throughput Rust/Go consumers subscribe to filtered streams.
# Consumer connects to provider Yellowstone endpoint
# Filter by owner program id and account memcmp- Lower latency than polling RPC for indexers.
- Requires managed provider or self-hosted stack.
- See Yellowstone gRPC.
8. Webhook Ingestion
Provider pushes events to your HTTPS endpoint.
# Helius webhook -> POST https://api.yourapp.com/helius- No long-lived WebSocket server required on your side.
- Verify signatures on webhook payloads per provider docs.
- See Webhooks.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.