You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/pages/en/substreams.mdx
+21-28Lines changed: 21 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,43 +4,36 @@ title: Substreams
4
4
5
5

6
6
7
-
Substreams is a powerful blockchain indexing technology developed for The Graph Network. It enables developers to write Rust modules, compose data streams alongside the community, and provide extremely high-performance indexing due to parallelization in a streaming-first approach.
7
+
Substreams is a powerful blockchain indexing technology developed to improve The Graph Network:
8
+
- Substreams allows you to speed up the indexing times of your subgraph.
9
+
- Substreams allows you to index non-EVM data (Solana, Injective, Starknet, Vara...)
8
10
9
-
With Substreams, developers can quickly extract data from different blockchains (Ethereum, BNB, Solana, ect.) and send it to various locations of their choice, such as a Postgres database, a Mongo database, or a Subgraph. Additionally, Substreams packages enable developers to specify which data they want to extract from the blockchain.
11
+
This is possible because your subgraph can use a Substreams package as a data source, thus creating a Substreams-powered Subgraph (SpS).
12
+
A Substreams package a binary file that contains all the definitions of the data that you want to extract from the blockchain (similar to the `mapping.ts` file of your subgraph).
10
13
11
-
## How Substreams Works in 4 Steps
14
+
The following example shows a subgraph manifest (`subgraph.yaml`) that uses a Substreams package as data source, thus receiving the data extracted by the Substreams.
15
+
Then, you can use this data in your `mapping.ts` and perform all the transformations needed as a usual subgraph.
12
16
13
-
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).
There are many Substreams packages already built that you can simply import into your subgraph.
22
+
[substreams.dev](https://substreams.dev) is a Substreams registry where you can explore different Substreams packages for several blockchain networks.
26
23
27
-
2.**You wrap up your Rust program into a WASM module just by running a single CLI command.**
24
+
// image
28
25
29
-
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.
26
+
## Create Your Own Substreams Package
30
27
31
-
4.**You select a [sink](https://substreams.streamingfast.io/documentation/consume/other-sinks), a place where you want to send the transformed data** (a Postgres database or a Subgraph, for example).
28
+
If you can't find a Substreams package that fits your needs, you can create your own package.
29
+
Creating a Substreams involves a Rust function that selects which specific data you want to extract from the network.
32
30
33
-
## Substreams Documentation
31
+
However, the Substreams CLI allows you to auto-generate a Substreams project without writing any code.
32
+
You can import Solana transactions or Vara extrinsics in your subgraph by using the auto-generation tools provided by The Graph.
34
33
35
-
The official Substreams documentation is currently maintained by the StreamingFast team [on the StreamingFast website](https://substreams.streamingfast.io/).
34
+
In the folllowing example, you run the `substreams init` command (similar to the `graph init` command), where you can select which kind of project you want to initialize.
35
+
You can choose among a variety of project generations (Solana transactions, EVM events and calls, Starknet transactions...).
36
36
37
-
To learn about the latest version of Substreams CLI, which enables developers to bootstrap a Substreams project without any code, please check [Substreams Codegen](https://streamingfastio.medium.com/substreams-codegen-no-code-tool-to-bootstrap-your-project-a11efe0378c6).
37
+
// image
38
38
39
-
### Getting Started
40
-
41
-
- In order to develop and deploy a Substreams, [you must install the Substreams CLI](https://substreams.streamingfast.io/documentation/consume/installing-the-cli).
42
-
- Then, run your first Substreams by following the [Quickstart Tutorial](https://substreams.streamingfast.io/documentation/develop/init-project).
43
-
44
-
### Expand Your Knowledge
45
-
46
-
- Take a look at the [Ethereum Explorer Tutorial](https://substreams.streamingfast.io/tutorials/evm) to learn about the basic transformations you can create with Substreams.
39
+
From the generated project, you can run `substreams codegen subgraph` to convert the Substreams project into a ready-to-deploy subgraph project!
The easiest way to get started with Substreams is by using one of the auto-generation tools. The Substreams CLI provides the `substreams init` command, which will allow you to initialize your Substreams project for several blockchains (EVM, Solana, Injective...).
8
+
9
+
The Substreams CLI is pretty similar to The Graph CLI: you install it in your computer and execution the different commands available.
10
+
11
+
### The Development Environment
12
+
13
+
To facilitate the development of Substreams-powered Subgraphs, a local development environment for VSCode is available, the [substreams-starter](https://github.com/streamingfast/substreams-starter) project.
14
+
15
+
The development environment is a VSCode extension that spins up all the necessary dependencies in Docker containers:
16
+
- A terminal-based environment with the Substreams CLI pre-installed, so you don't have to install
17
+
- A Graph Node instance, which you can uses to test your subgraph locally.
18
+
- A PostgreSQL instance, which is used by the Graph Node to store all the necessary data for your subgraphs.
19
+
- An IPFS instance, which is used by the Graph Node to store the _build_ files of the subgraph.
20
+
21
+
You can run the development environment locally (you need both VSCode and Docker) or remotely through GitHub codespaces.
22
+
23
+
#### Run the Development Environment Locally
24
+
25
+
To run it locally, simply open the [substreams-starter](https://github.com/streamingfast/substreams-starter) in your local VSCode application.
26
+
27
+
#### Run the Development Environment Remotely
28
+
29
+
To run it in GitHub codespace, open [this link](https://github.com/codespaces/new/streamingfast/substreams-starter?machine=standardLinux32gb) (`https://github.com/codespaces/new/streamingfast/substreams-starter?machine=standardLinux32gb`) in your browser. Log in with GitHub and you will get access to a VSCode instance in your browser.
30
+
31
+
### Initialize Your Substreams Project
32
+
33
+
In the development environment, you will have access to the `substreams init` command. Depending on the type of project that you want to initialize, the flow will be different. Choose which blockchain you want to index:
34
+
35
+
36
+
37
+
### Generate Your Subgraph Project
38
+
39
+
From the generated Substreams project, you can create a Substreams-powered Subgraph project that uses the Substreams as data source.
40
+
41
+
In the folder of the Substreams project, run `substreams codegen subgraph` and choose the module that you want your subgraph to consume. A new `subgraph` folder will be created with ready-to-deploy subgraph.
0 commit comments