Skip to content

Sinks and materialization

Decide how to turn Substreams output into queryable application state.

Decide how a block stream becomes data your application can query. A sink writes Substreams output to your database, files, or queue and tracks its cursor so it can recover after a disconnect. You choose between a standard sink and your own consumer.

Consumption modes

Run a consumer or sink in your own infrastructure, or contact GraphOps about enterprise sink hosting.

ModeGraphOps supportUse it for
Direct gRPC streamSelf-serviceApplication consumers and custom materializers.
Customer-run sinkSelf-serviceWriting to SQL, files, queues, or custom stores.
Hosted sinkEnterpriseGraphOps-managed sink hosting. Contact support in the platform UI.

Choose a sink

Each destination has a standard Substreams tool. The CLI sinks take your GraphOps endpoint with -e and read your API key from SUBSTREAMS_API_KEY.

DestinationToolGuide
Your applicationSubstreams libraries for JavaScript, Go, Rust, or PythonSubstreams:Stream
Postgres or ClickHousesubstreams sink postgres or substreams sink clickhouse, built into the CLIRun a sink, Substreams:SQL
Filessubstreams sink protojson for JSONL; substreams-sink-files for CSV or ParquetProtoJSON, Files
Google Cloud Pub/Subsubstreams sink pubsubSubstreams:PubSub

The SQL sink needs an output module that emits DatabaseChanges, usually db_out, or Protobuf output annotated for relational mappings.

Sink responsibilities

A standard sink takes care of most of these. If you write your own consumer, it must do all of them.

A sink decodes the output module, applies each block's data to durable state, and persists the cursor only after that commit. On an undo signal it rolls local state back to the last valid block.

A production sink should:

  • Decode the output module type.
  • Apply block-scoped data to durable state.
  • Persist cursors after durable commits.
  • Handle undo signals and rollback local state.
  • Expose metrics for processed blocks, bytes out, bytes read, bytes written, lag, retries, and failures.
  • Bound worker concurrency according to the organization's plan.

Next steps