There are two methods of creating Substreams-Powered Subgraphs:
Using Substreams triggers: 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.
Using Entity Changes: 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.
Add Rust Target
Generate Protobuf Types
This command generates types in /src/pb.
Build Substreams
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.
Generate Subgraph Project
Navigate to the Subgraph Directory
Edit the following files as needed:
mappings.ts
schema.graphql
subgraph.yaml
Install Dependencies
Generate AssemblyScript & Protobuf Bindings
Build Subgraph
The final step is to deploy the subgraph using the deployment command. See Manage Subgraph