substreams > Introduction

Substreams

Reading time: 2 min

Logo Substreams

Substreams is a powerful blockchain indexing technology designed to enhance performance and scalability within The Graph Network. It offers the following features:

  • Accelerated Indexing: Substreams reduce subgraph indexing time thanks to a parallelized engine, enabling faster data retrieval and processing.
  • Multi-Chain Support: Substreams expand indexing capabilities beyond EVM-based chains, supporting ecosystems like Solana, Injective, Starknet, and Vara.
  • Multi-Sink Support: Subgraph, Postgres database, Clickhouse, Mongo database

Le fonctionnement de Substreams en 4 étapes

Lien vers cette section
  1. You write a Rust program, which defines the transformations that you want to apply to the blockchain data. For example, the following Rust function extracts relevant information from an Ethereum block (number, hash, and parent hash).

    fn get_my_block(blk: Block) -> Result<MyBlock, substreams::errors::Error> {
    let header = blk.header.as_ref().unwrap();
    Ok(MyBlock {
    number: blk.number,
    hash: Hex::encode(&blk.hash),
    parent_hash: Hex::encode(&header.parent_hash),
    })
    }
  2. You wrap up your Rust program into a WASM module just by running a single CLI command.

  3. The WASM container is sent to a Substreams endpoint for execution. The Substreams provider feeds the WASM container with the blockchain data and the transformations are applied.

  4. You select a sink, a place where you want to send the transformed data (a Postgres database or a Subgraph, for example).

Documentation des Substreams

Lien vers cette section

La documentation officielle de Substreams est actuellement maintenue par l'équipe de StreamingFast sur le site web de StreamingFast.

To learn about the latest version of Substreams CLI, which enables developers to bootstrap a Substreams project without any code, please check Substreams Codegen.

Élargissez vos connaissances

Lien vers cette section

Substreams Registry

Lien vers cette section

A Substreams package is a precompiled binary file that defines the specific data you want to extract from the blockchain, similar to the mapping.ts file in traditional subgraphs. Visit substreams.dev to explore a growing collection of ready-to-use Substreams packages across various blockchain networks.

Modifier une page

Précédente
How to Secure API Keys Using Next.js Server Components
Suivante
Introduction
Modifier une page