Skip to content

Commit c1758de

Browse files
committed
Draft
1 parent cc8258e commit c1758de

File tree

2 files changed

+98
-7
lines changed

2 files changed

+98
-7
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
3+
Getting started with a Solana Substreams-powered Subgraph is really easy by using the auto-generation tools contained in the `substreams init` command. Essentially it requires two steps: creating a Substreams project and creating a Subgraph project based on that Substreams project.
4+
5+
> **Note**: It is recommended that you run everything inside the Substreams Development Environment. Take a look at the [Getting Started page](./getting-started.md) or directly clone the [substreams-starter](https://github.com/streamingfast/substreams-starter) repository.
6+
7+
## Generate the Substreams Project
8+
9+
The first step is creating a Substreams project and generating a Substreams package (`.spkg` file) that the subgraph can use as data source.
10+
11+
1. Run `substreams init`, which will show the different options to intialize your project.
12+
13+
// image
14+
15+
2. Choose the preferred option to initialize your Solana project:
16+
17+
- `sol-minimal`: will create a very simple Substreams, just extracting raw data from the block (it will generate Rust code).
18+
- `sol-transactions`: will create a Substreams that extracts Solana transactions filtered by one or several Program IDs. (it will NOT generate Rust code, as it relies on the Solana Foundational Modules).
19+
20+
3. Complete the rest of information needed, such as the project name or the Program IDs that you want to use to filter the transactions.
21+
22+
4. Once you are done answering all the questions, a Substreams project will be generated in the specified folder.
23+
24+
// image
25+
26+
5. Follow the instructions provided to authenticate, build and run the Substreams project.
27+
28+
To build the project and **generate the Substreams package (`.spkg`)**:
29+
30+
```bash
31+
substreams build
32+
```
33+
34+
To autenthicate with one of the Substreams providers:
35+
36+
```bash
37+
substreams auth
38+
```
39+
40+
To run the Substreams in your command-line terminal:
41+
42+
```bash
43+
substreams gui
44+
```
45+
46+
## Generate the Subgraph Project
47+
48+
From the Substreams `.spkg` file, which contains all the data that you want to extract from the blockchain, you can generate a subgraph project.
49+
50+
1. Run `substreams codegen subgraph`.
51+
A new folder, `subgraph`, will be created.
52+
53+
2. The generated project is standard subgraph project, where the `subgraph.yaml` file uses the Substreams package as data source. By default, the code contained in the `mappings.ts` file is pretty simple. It is up to you to decide what entities you want to create with the data extracted from the Substreams.
54+
55+
3. Follow the instructions provided to build your subgraph.
56+
57+
To install the Node modules:
58+
59+
```bash
60+
npm install
61+
```
62+
63+
To generate the GraphQL schema of the subgraph (i.e. the output of the subgraph):
64+
65+
```bash
66+
npm run codegen
67+
```
68+
69+
To generate Protobuf schema of the Substreams (i.e. the output of the Substreams and the input of the subgraph):
70+
71+
```bash
72+
npm run protogen
73+
```
74+
75+
To build your subgraph:
76+
77+
```bash
78+
npm run build
79+
```
80+
81+
(All the previous command starting with `npm run` are wrappers defined in the `package.json` file).
82+
83+
6. If you have a Graph Node instance running locally, you can deploy and test your subgraph.
84+
It is recommended that you run everything inside the [substreams-starter environment](https://github.com/streamingfast/substreams-starter).
85+
86+
> **Note**: To run the following command, you need a working Substreams Developer Environment. If you are running Graph Node outside of the Developer Environment, take a look at the `package.json` file of the project to review the Graph CLI command executed.
87+
88+
To create the subgraph:
89+
90+
```bash
91+
npm run create-local
92+
```
93+
94+
To deploy the subgraph:
95+
96+
```bash
97+
npm run deploy-local
98+
```

website/pages/en/substreams/getting-started.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,4 @@ In the development environment, you will have access to the `substreams init` co
3434

3535

3636

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.
42-
43-
4437

0 commit comments

Comments
 (0)