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/src/pages/en/subgraphs/quick-start.mdx
+27-67Lines changed: 27 additions & 67 deletions
Original file line number
Diff line number
Diff line change
@@ -2,24 +2,28 @@
2
2
title: Quick Start
3
3
---
4
4
5
-
Learn how to easily build, publish and query a [Subgraph](/subgraphs/developing/developer-faq/#1-what-is-a-subgraph) on The Graph.
5
+
Create, deploy, and query a [Subgraph](/subgraphs/developing/developer-faq/#1-what-is-a-subgraph) on The Graph Network.
6
+
7
+
By the end, you'll have:
8
+
9
+
- Initialized a Subgraph from a smart contract
10
+
- Deployed it to Subgraph Studio for testing
11
+
- Published to The Graph Network for decentralized indexing
6
12
7
13
## Prerequisites
8
14
9
15
- A crypto wallet
10
-
- A smart contract address on a [supported network](/supported-networks/)
11
-
-[Node.js](https://nodejs.org/) installed
12
-
- A package manager of your choice (`npm`, `yarn` or `pnpm`)
16
+
- A deployed smart contract on a [supported network](/supported-networks/)
17
+
-[Node.js](https://nodejs.org/) & a package manager of your choice (`npm`, `yarn` or `pnpm`)
13
18
14
19
## How to Build a Subgraph
15
20
16
21
### 1. Create a Subgraph in Subgraph Studio
17
22
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
+
1. Go to [Subgraph Studio](https://thegraph.com/studio/)
24
+
2. Connect your wallet
25
+
3. Click "Create a Subgraph"
26
+
4. Name it in Title Case: "Subgraph Name Chain Name"
23
27
24
28
### 2. Install the Graph CLI
25
29
@@ -37,20 +41,22 @@ Using [yarn](https://yarnpkg.com/):
37
41
yarn global add @graphprotocol/graph-cli
38
42
```
39
43
40
-
### 3. Initialize your Subgraph
44
+
Verify install:
41
45
42
-
> You can find commands for your specific Subgraph on the Subgraph page in [Subgraph Studio](https://thegraph.com/studio/).
46
+
```sh
47
+
graph --version
48
+
```
49
+
50
+
### 3. Initialize your Subgraph
43
51
44
-
The `graph init` command will automatically create a scaffold of a Subgraph based on your contract's events.
52
+
> You can find commands for your specific Subgraph in [Subgraph Studio](https://thegraph.com/studio/).
45
53
46
-
The following command initializes your Subgraph from an existing contract:
54
+
The following command initializes your Subgraph from an existing contract and indexes events:
47
55
48
56
```sh
49
57
graph init
50
58
```
51
59
52
-
If your contract is verified on the respective blockscanner where it is deployed (such as [Etherscan](https://etherscan.io/)), then the ABI will automatically be created in the CLI.
53
-
54
60
When you initialize your Subgraph, the CLI will ask you for the following information:
55
61
56
62
-**Protocol**: Choose the protocol your Subgraph will be indexing data from.
@@ -59,19 +65,17 @@ When you initialize your Subgraph, the CLI will ask you for the following inform
59
65
-**Ethereum network** (optional): You may need to specify which EVM-compatible network your Subgraph will be indexing data from.
60
66
-**Contract address**: Locate the smart contract address you’d like to query data from.
61
67
-**ABI**: If the ABI is not auto-populated, you will need to input it manually as a JSON file.
62
-
-**Start Block**: You should input the start block to optimize Subgraph indexing of blockchain data. Locate the start block by finding the block where your contract was deployed.
68
+
-**Start Block**: You should input the start block where the contract was deployed to optimize Subgraph indexing of blockchain data.
63
69
-**Contract Name**: Input the name of your contract.
64
70
-**Index contract events as entities**: It is suggested that you set this to true, as it will automatically add mappings to your Subgraph for every emitted event.
65
71
-**Add another contract** (optional): You can add another contract.
66
72
67
-
See the following screenshot for an example for what to expect when initializing your Subgraph:
73
+
See the following screenshot for an example of what to expect when initializing your Subgraph:
68
74
69
75

70
76
71
77
### 4. Edit your Subgraph
72
78
73
-
The `init` command in the previous step creates a scaffold Subgraph that you can use as a starting point to build your Subgraph.
74
-
75
79
When making changes to the Subgraph, you will mainly work with three files:
76
80
77
81
- Manifest (`subgraph.yaml`) - defines what data sources your Subgraph will index.
@@ -82,9 +86,7 @@ For a detailed breakdown on how to write your Subgraph, check out [Creating a Su
82
86
83
87
### 5. Deploy your Subgraph
84
88
85
-
> Remember, deploying is not the same as publishing.
86
-
87
-
When you **deploy** a Subgraph, you push it to [Subgraph Studio](https://thegraph.com/studio/), where you can test, stage and review it. A deployed Subgraph's indexing is performed by the [Upgrade Indexer](https://thegraph.com/blog/upgrade-indexer/), which is a single Indexer owned and operated by Edge & Node, rather than by the many decentralized Indexers in The Graph Network. A **deployed** Subgraph is free to use, rate-limited, not visible to the public, and meant to be used for development, staging, and testing purposes.
89
+
When you **deploy** a Subgraph, you push it to [Subgraph Studio](https://thegraph.com/studio/), where you can test, stage and review it. A deployed Subgraph's indexing is performed by the [Upgrade Indexer](https://thegraph.com/blog/upgrade-indexer/), which is a single Indexer owned and operated by Edge & Node. A **deployed** Subgraph is free to use, rate-limited, not visible to the public, and meant to be used for development, staging, and testing purposes.
88
90
89
91
Once your Subgraph is written, run the following commands:
90
92
@@ -103,8 +105,6 @@ Authenticate and deploy your Subgraph. The deploy key can be found on the Subgra
103
105
graph deploy <SUBGRAPH_SLUG>
104
106
```
105
107
106
-
The CLI will ask for a version label. It's strongly recommended to use [semantic versioning](https://semver.org/), e.g. `0.0.1`.
107
-
108
108
### 6. Review your Subgraph
109
109
110
110
If you’d like to test your Subgraph before publishing it, you can use [Subgraph Studio](https://thegraph.com/studio/) to do the following:
@@ -121,53 +121,13 @@ When your Subgraph is ready for a production environment, you can publish it to
121
121
122
122
- It makes your Subgraph available to be to indexed by the decentralized [Indexers](/indexing/overview/) on The Graph Network.
123
123
- It removes rate limits and makes your Subgraph publicly searchable and queryable in [Graph Explorer](https://thegraph.com/explorer/).
124
-
- It makes your Subgraph available for [Curators](/resources/roles/curating/) to curate it.
125
-
126
-
> The greater the amount of GRT you and others curate on your Subgraph, the more Indexers will be incentivized to index your Subgraph, improving the quality of service, reducing latency, and enhancing network redundancy for your Subgraph.
124
+
- It makes your Subgraph available for [Curators](/resources/roles/curating/) to add curation signal.
127
125
128
-
#### Publishing with Subgraph Studio
129
-
130
-
To publish your Subgraph, click the Publish button in the dashboard.
126
+
To publish your Subgraph, click the Publish button in the dashboard and select your network.
131
127
132
128

133
129
134
-
Select the network to which you would like to publish your Subgraph.
135
-
136
-
#### Publishing from the CLI
137
-
138
-
As of version 0.73.0, you can also publish your Subgraph with the Graph CLI.
139
-
140
-
Open the `graph-cli`.
141
-
142
-
Use the following commands:
143
-
144
-
```sh
145
-
graph codegen && graph build
146
-
```
147
-
148
-
Then,
149
-
150
-
```sh
151
-
graph publish
152
-
```
153
-
154
-
3. A window will open, allowing you to connect your wallet, add metadata, and deploy your finalized Subgraph to a network of your choice.
155
-
156
-

157
-
158
-
To customize your deployment, see [Publishing a Subgraph](/subgraphs/developing/publishing/publishing-a-subgraph/).
159
-
160
-
#### Adding signal to your Subgraph
161
-
162
-
1. To attract Indexers to query your Subgraph, you should add GRT curation signal to it.
163
-
164
-
- This action improves quality of service, reduces latency, and enhances network redundancy and availability for your Subgraph.
165
-
166
-
2. If eligible for indexing rewards, Indexers receive GRT rewards based on the signaled amount.
167
-
168
-
- It’s recommended to curate at least 3,000 GRT to attract 3 Indexers. Check reward eligibility based on Subgraph feature usage and supported networks.
169
-
170
-
To learn more about curation, read [Curating](/resources/roles/curating/).
130
+
> It is recommended that you curate your own Subgraph with at least 3,000 GRT to incentivize indexing.
171
131
172
132
To save on gas costs, you can curate your Subgraph in the same transaction you publish it by selecting this option:
0 commit comments