LogoLogo
  • Platform
    • Manage Your Account
    • Technical Support
  • Services
    • Shared Indexing
      • Hosted Subgraphs
        • Quick Start Guide
          • Purchase Subscription
        • Manage Hosted Subgraphs
          • Webhook
          • Settings
      • Hosted SubQuery
        • Quick Start Guide
          • Purchase Subscription
        • Manage Hosted SubQuery
          • Settings
    • Dedicated Indexing
      • Graph Nodes
        • Quick Start Guide
          • Purchase Subscription
        • Graph Node Manual
          • Deploy Graph Node
          • View Analytics
          • Manage Addon Services
          • Ledger Data Pruning
        • Subgraph Manual
          • Manage Subgraph
          • Webhook Management
          • Index Data Pruning
          • Settings
          • Substreams-Powered Subgraphs
      • Subquery Nodes
        • Quick Start Guide
          • Purchase Subscription
        • Subquery Node Manual
          • Deploy Subquery Node
          • View Analytics
          • Manage Addon Services
        • Subquery Manual
          • Manage Subquery
          • Settings
Powered by GitBook
On this page
  • Create Substreams-Powered Subgraphs
  • Deploy Substreams-Powered Subgraphs
Export as PDF
  1. Services
  2. Dedicated Indexing
  3. Graph Nodes
  4. Subgraph Manual

Substreams-Powered Subgraphs

PreviousSettingsNextSubquery Nodes

Last updated 20 days ago

An internet connection is required for generating Rust bindings.

  1. Direct Download

LINK=$(curl -s https://api.github.com/repos/bufbuild/buf/releases/latest | \
awk "/download.url.*buf-Linux-$(uname -m)\"/ {print \$2}" | sed 's/"//g')

echo Downloading $LINK

curl -L $LINK -o /usr/bin/buf
  1. Using npm

npm install @bufbuild/buf

Rust

A complete Rust environment is necessary for developing Substreams modules.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

source $HOME/.cargo/env

Create Substreams-Powered Subgraphs

There are two methods of creating Substreams-Powered Subgraphs:

  1. Using Substreams : Consume from any Substreams module by importing the Protobuf model through a Subgraph handler and move all your logic into a Subgraph. This method creates the Subgraph entities directly in the Subgraph.

  2. Using : By writing more of the logic into Substreams, you can consume the module’s output directly into Subgraph. In Subgraph you can use the Substreams data to create your Subgraph entities.

You can choose where to place your logic, either in the Subgraph or Substreams. However, consider what aligns with your data needs, as Substreams has a parallelized model, and triggers are consumed linearly.

Deploy Substreams-Powered Subgraphs

Before deploying a substream-powered subgraph, ensure substream are enabled for the blockchain network in Graph Node.

  1. Add Rust Target

rustup target add wasm32-unknown-unknown
  1. Generate Protobuf Types

substreams protogen

This command generates types in /src/pb.

  1. Build Substreams

substreams build

This command creates a Substream package (.spkg), which can be used as a data source for a subgraph to access pre-indexed blockchain data streams.

  1. Generate Subgraph Project

substreams codegen subgraph
  1. Navigate to the Subgraph Directory

Edit the following files as needed:

  • mappings.ts

  • schema.graphql

  • subgraph.yaml

  1. Install Dependencies

npm install
  1. Generate AssemblyScript & Protobuf Bindings

npm run generate
  1. Build Subgraph

npm run build

The final step is to deploy the subgraph using the deployment command. See

triggers
Entity Changes⁠
Manage Subgraph