# Substreams Sink

> Expert knowledge for consuming Substreams data from Solana/SVM modules. Use when building sinks, real-time data pipelines, or integrating Substreams outputs into applications. Use when this capability is needed.

- Skill: `tomevault-io/substreams-sink` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/substreams-sink`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/substreams-sink/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/substreams-sink

---


# Substreams Sink Development Expert (SVM)

Expert assistant for consuming Solana/SVM Substreams data — building production-grade sinks and data pipelines.

## Core Concepts

### What is a Substreams Sink?

A Substreams sink is an application that:
- **Connects** to a Substreams endpoint via gRPC
- **Streams** processed blockchain data from a Substreams package (.spkg)
- **Handles** cursor persistence for resumability
- **Manages** chain reorganizations gracefully
- **Processes** the data into your destination (database, queue, etc.)

> **Note:** Before building a custom sink, consider using existing solutions:
> - **[substreams-sink-sql](https://github.com/streamingfast/substreams-sink-sql)** — For PostgreSQL and ClickHouse. Handles cursor management, reorgs, batching, and schema management out of the box.
> - **[substreams-sink-kv](https://github.com/streamingfast/substreams-sink-kv)** — For key-value stores.
> - **[substreams-sink-files](https://github.com/streamingfast/substreams-sink-files)** — For file-based outputs (JSON, CSV, Parquet).

### SVM-Specific Considerations

- **Solana endpoint**: `solana.substreams.pinax.network:443`
- **Output types**: Solana modules output protobuf types like `Events` (per-DEX) or `DatabaseChanges` (aggregate)
- **Address encoding**: Solana addresses are base58-encoded (not hex)
- **High throughput**: Solana produces blocks every ~400ms with many transactions; sinks must handle high data volume

### Authentication

```bash
export SUBSTREAMS_API_KEY="your-api-key"
# Or
export SUBSTREAMS_API_TOKEN="your-jwt-token"
```

Get your API key from [thegraph.market](https://thegraph.market) or [pinax.network](https://pinax.network).

## References

See the `references/` directory for detailed guides:
- `rust-sink.md` — Rust sink implementation
- `cursor-reorg.md` — Cursor management & reorg handling

## Quick Start: SQL Sink (Recommended)

For most use cases, use `substreams-sink-sql` with the pre-built SVM SPKGs:

### ClickHouse

```bash
substreams-sink-sql run \
  "clickhouse://default:@localhost:9000/solana" \
  "https://github.com/pinax-network/substreams-svm/releases/download/svm-dex-v0.3.1/clickhouse-svm-dex-v0.3.1.spkg" \
  db_out
```

### PostgreSQL

```bash
substreams-sink-sql run \
  "postgres://user:pass@localhost:5432/solana?sslmode=disable" \
  "https://github.com/pinax-network/substreams-svm/releases/download/svm-dex-v0.3.1/postgres-svm-dex-v0.3.1.spkg" \
  db_out
```

## Available SVM SPKGs

| Module | Description | Output |
|--------|-------------|--------|
| `svm-dex` | All DEX swaps (Raydium, Jupiter, Orca, PumpFun, Meteora, etc.) | `DatabaseChanges` |
| `svm-transfers` | SPL token + native SOL transfers | `DatabaseChanges` |
| `svm-balances` | Token balance changes | `DatabaseChanges` |
| `svm-accounts` | Account creation/updates | `DatabaseChanges` |
| `svm-metadata` | Metaplex token metadata | `DatabaseChanges` |

Each is available in ClickHouse and PostgreSQL variants.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/pinax-network) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

