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/quick-start.mdx
+41-49Lines changed: 41 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,26 @@
2
2
title: Quick Start
3
3
---
4
4
5
-
Learn how to easily publish and query a [subgraph](/developing/developer-faqs/#1-what-is-a-subgraph) on The Graph.
5
+
Learn how to easily build, publish and query a [subgraph](/developing/developer-faqs/#1-what-is-a-subgraph) on The Graph.
6
6
7
-
## Prerequisites for this guide
7
+
## Prerequisites
8
8
9
9
- A crypto wallet
10
-
- A smart contract address on one of the [supported networks](/developing/supported-networks/)
10
+
- A smart contract address on a [supported network](/developing/supported-networks/)
11
+
-[Node.js](https://nodejs.org/) installed
12
+
- A package manager of your choice (`npm`, `yarn` or `pnpm`)
11
13
12
-
## Step-by-step
14
+
## How to Build a Subgraph
13
15
14
-
### 1. Install the Graph CLI
16
+
### 1. Create a subgraph in Subgraph Studio
15
17
16
-
You must have [Node.js](https://nodejs.org/) and a package manager of your choice (`npm`, `yarn` or `pnpm`) installed to use the Graph CLI. Check for the [most recent](https://github.com/graphprotocol/graph-tooling/releases?q=%40graphprotocol%2Fgraph-cli&expanded=true) CLI version.
18
+
Go to [Subgraph Studio](https://thegraph.com/studio/) and connect your wallet.
19
+
20
+
Subgraph Studio lets you create, manage, deploy, and publish subgraphs, as well as create and manage API keys.
21
+
22
+
Click "Create a Subgraph". It is recommended to name the subgraph in Title Case: "Subgraph Name Chain Name".
23
+
24
+
### 2. Install the Graph CLI
17
25
18
26
On your local machine, run one of the following commands:
19
27
@@ -29,40 +37,19 @@ Using [yarn](https://yarnpkg.com/):
29
37
yarn global add @graphprotocol/graph-cli
30
38
```
31
39
32
-
### 2. Create your subgraph
33
-
34
-
If your contract has events, the `init` command will automatically create a scaffold of a subgraph.
35
-
36
-
#### Create via Graph CLI
37
-
38
-
Use the following command to create a subgraph in Subgraph Studio using the CLI:
39
-
40
-
```sh
41
-
graph init --product subgraph-studio
42
-
```
43
-
44
-
#### Create via Subgraph Studio
45
-
46
-
Subgraph Studio lets you create, manage, deploy, and publish subgraphs, as well as create and manage API keys.
47
-
48
-
1. Go to [Subgraph Studio](https://thegraph.com/studio/) and connect your wallet.
49
-
2. Click "Create a Subgraph". It is recommended to name the subgraph in Title Case: "Subgraph Name Chain Name".
50
-
51
-
For additional information on subgraph creation and the Graph CLI, see [Creating a Subgraph](/developing/creating-a-subgraph).
52
-
53
40
### 3. Initialize your subgraph
54
41
55
-
#### From an existing contract
42
+
> You can find commands for your specific subgraph on the subgraph page in [Subgraph Studio](https://thegraph.com/studio/).
43
+
44
+
The `graph init` command will automatically create a scaffold of a subgraph based on your contract's events.
56
45
57
46
The following command initializes your subgraph from an existing contract:
58
47
59
48
```sh
60
-
graph init<SUBGRAPH_SLUG>
49
+
graph init
61
50
```
62
51
63
-
> Note: If your contract was verified on Etherscan, then the ABI will automatically be created in the CLI.
64
-
65
-
You can find commands for your specific subgraph on the subgraph page in [Subgraph Studio](https://thegraph.com/studio/).
52
+
If your contract was verified on Etherscan, then the ABI will automatically be created in the CLI.
66
53
67
54
When you initialize your subgraph, the CLI will ask you for the following information:
68
55
@@ -81,7 +68,7 @@ See the following screenshot for an example for what to expect when initializing
81
68
82
69

83
70
84
-
### 4. Write your subgraph
71
+
### 4. Edit your subgraph
85
72
86
73
The `init` command in the previous step creates a scaffold subgraph that you can use as a starting point to build your subgraph.
87
74
@@ -97,17 +84,17 @@ For a detailed breakdown on how to write your subgraph, check out [Creating a Su
97
84
98
85
Remember, deploying is not the same as publishing.
99
86
100
-
- When you deploy a subgraph, you push it to [Subgraph Studio](https://thegraph.com/studio/), where you can test, stage and review it.
101
-
- When you publish a subgraph, you are publishing it onchain to the decentralized network.
87
+
When you deploy a subgraph, you push it to [Subgraph Studio](https://thegraph.com/studio/), where you can test, stage and review it.
102
88
103
-
1. Once your subgraph is written, run the following commands:
89
+
When you publish a subgraph, you are publishing it onchain to the decentralized network.
90
+
91
+
Once your subgraph is written, run the following commands:
104
92
105
93
```sh
106
-
graph codegen
107
-
graph build
94
+
graph codegen && graph build
108
95
```
109
96
110
-
2.Authenticate and deploy your subgraph. The deploy key can be found on the subgraph's page in Subgraph Studio.
97
+
Authenticate and deploy your subgraph. The deploy key can be found on the subgraph's page in Subgraph Studio.
@@ -118,12 +105,11 @@ Remember, deploying is not the same as publishing.
118
105
graph deploy <SUBGRAPH_SLUG>
119
106
```
120
107
121
-
- The CLI will ask for a version label.
122
-
- It's strongly recommended to use [semantic versioning](https://semver.org/), e.g. `0.0.1`. That said, you can choose any string for the version such as: `v1`, `version1`, `asdf`, etc.
108
+
The CLI will ask for a version label. It's strongly recommended to use [semantic versioning](https://semver.org/), e.g. `0.0.1`.
123
109
124
110
### 6. Review your subgraph
125
111
126
-
If you’d like to examine your subgraph before publishing it to the network, you can use [Subgraph Studio](https://thegraph.com/studio/) to do the following:
112
+
If you’d like to test your subgraph before publishing it, you can use [Subgraph Studio](https://thegraph.com/studio/) to do the following:
127
113
128
114
- Run a sample query.
129
115
- Analyze your subgraph in the dashboard to check information.
@@ -133,19 +119,23 @@ If you’d like to examine your subgraph before publishing it to the network, yo
133
119
134
120
### 7. Publish your subgraph to The Graph Network
135
121
136
-
Publishing a subgraph to the decentralized network makes it available for [Curators](/network/curating/) to begin curating it and [Indexers](/network/indexing/) to begin indexing it.
122
+
Publishing a subgraph to the decentralized network is an onchain action that makes your subgraph available for [Curators](/network/curating/) to curate it and [Indexers](/network/indexing/) to index it.
137
123
138
124
#### Publishing with Subgraph Studio
139
125
140
-
1. To publish your subgraph, click the Publish button in the dashboard.
141
-
2. Select the network to which you would like to publish your subgraph.
126
+
To publish your subgraph, click the Publish button in the dashboard.
127
+
128
+

129
+
130
+
Select the network to which you would like to publish your subgraph.
142
131
143
132
#### Publishing from the CLI
144
133
145
134
As of version 0.73.0, you can also publish your subgraph with the Graph CLI.
146
135
147
-
1. Open the `graph-cli`.
148
-
2. Use the following commands:
136
+
Open the `graph-cli`.
137
+
138
+
Use the following commands:
149
139
150
140
```sh
151
141
graph codegen && graph build
@@ -165,7 +155,7 @@ To customize your deployment, see [Publishing a Subgraph](/publishing/publishing
165
155
166
156
#### Adding signal to your subgraph
167
157
168
-
1. To attract indexers to query your subgraph, you should add GRT curation signal to it.
158
+
1. To attract Indexers to query your subgraph, you should add GRT curation signal to it.
169
159
170
160
- This action improves quality of service, reduces latency, and enhances network redundancy and availability for your subgraph.
171
161
@@ -181,6 +171,8 @@ To save on gas costs, you can curate your subgraph in the same transaction you p
181
171
182
172
### 8. Query your subgraph
183
173
184
-
Now, you can query your subgraph by sending GraphQL queries to its Query URL, which you can find by clicking the Query button.
174
+
You now have access to 100,000 free queries per month with your subgraph on The Graph Network!
175
+
176
+
You can query your subgraph by sending GraphQL queries to its Query URL, which you can find by clicking the Query button.
185
177
186
178
For more information about querying data from your subgraph, read [Querying The Graph](/querying/querying-the-graph/).
0 commit comments