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
+66-53Lines changed: 66 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,19 +2,18 @@
2
2
title: Quick Start
3
3
---
4
4
5
-
This guide walks you through the basics of publishing and querying a subgraph on The Graph easily.
5
+
Learn how to easily publish and query a subgraph on The Graph.
6
6
7
-
**Prerequisites for this guide:**
7
+
## Prerequisites for this guide
8
8
9
9
- A crypto wallet
10
-
- A smart contract address on the [supported network](/developing/supported-networks/) of your choice
11
-
- An API key
10
+
- A smart contract address on one of the [supported networks](/developing/supported-networks/)
12
11
13
12
## Step-by-Step
14
13
15
14
### 1. Install the Graph CLI
16
15
17
-
You must have [Node.js](https://nodejs.org/en) and 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.
16
+
You must have [Node.js](https://nodejs.org/) and 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
17
19
18
On your local machine, run one of the following commands:
20
19
@@ -30,26 +29,30 @@ Using [yarn](https://yarnpkg.com/):
30
29
yarn global add @graphprotocol/graph-cli
31
30
```
32
31
33
-
### 2. Create your subgraph
32
+
### 2. Create Your Subgraph
34
33
35
34
If your contract has events, the `init` command will automatically create a scaffold of a subgraph.
36
35
37
-
#### Create via CLI
36
+
#### Create via Graph CLI
38
37
39
-
Use the following command to create a subgraph in Subgraph Studio using CLI:`init --product subgraph-studio`
38
+
Use the following command to create a subgraph in Subgraph Studio using CLI:
40
39
41
-
#### **Create via Subgraph Studio**
40
+
```sh
41
+
init --product subgraph-studio
42
+
```
43
+
44
+
#### Create via Subgraph Studio
42
45
43
-
Subgraph Studio is a staging environment where you can create, manage, deploy, and publish subgraphs and API Keys.
46
+
Subgraph Studio has a staging environment where you can create, manage, deploy, and publish subgraphs and API Keys.
44
47
45
-
1. Go to the[Subgraph Studio](https://thegraph.com/studio/) and connect your wallet.
46
-
2. Click “Create a Subgraph." It is recommended to name the subgraph in Title Case: "Subgraph Name Chain Name."
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".
47
50
48
-
For additional information on subgraph creation and CLI, see [Creating a Subgraph](developing/creating-a-subgraph).
51
+
For additional information on subgraph creation and CLI, see [Creating a Subgraph](/developing/creating-a-subgraph).
49
52
50
53
### 3. Initialize Your Subgraph
51
54
52
-
#### **From an existing contract**
55
+
#### From an existing contract
53
56
54
57
The following command initializes your subgraph from an existing contract:
55
58
@@ -63,58 +66,58 @@ You can find commands for your specific subgraph on the subgraph page in [Subgra
63
66
64
67
When you initialize your subgraph, the CLI tool will ask you for the following information:
65
68
66
-
- Protocol: Choose the protocol your subgraph will be indexing data from
69
+
- Protocol: Choose the protocol your subgraph will be indexing data from.
67
70
- Subgraph slug: Create a name for your subgraph. Your subgraph slug is an identifier for your subgraph.
68
-
- Directory to create the subgraph in: Choose your local directory
69
-
- Ethereum network(optional): You may need to specify which EVM-compatible network your subgraph will be indexing data from
70
-
- Contract address: Locate the smart contract address you’d like to query data from
71
-
- ABI: If the ABI is not auto-populated, you will need to input it manually as a JSON file
71
+
- Directory to create the subgraph in: Choose your local directory.
72
+
- Ethereum network(optional): You may need to specify which EVM-compatible network your subgraph will be indexing data from.
73
+
- Contract address: Locate the smart contract address you’d like to query data from.
74
+
- ABI: If the ABI is not auto-populated, you will need to input it manually as a JSON file.
72
75
- 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.
73
-
- Contract Name: Input the name of your contract
74
-
- 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
75
-
- Add another contract(optional): You can add another contract.
76
+
- Contract Name: Input the name of your contract.
77
+
- 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.
78
+
- Add another contract(optional): You can add another contract.
76
79
77
80
See the following screenshot for an example for what to expect when initializing your subgraph:
The `init` command in the previous step creates a scaffold subgraph that you can use as a starting point to build your subgraph.
84
87
85
88
When making changes to the subgraph, you will mainly work with three files:
86
89
87
-
- Manifest (`subgraph.yaml`)- defines what datasources your subgraphs will index.
90
+
- Manifest (`subgraph.yaml`)- defines what datasources your subgraphs will index.
88
91
- Schema (`schema. graphql`) - defines what data you wish to retrieve from the subgraph.
89
92
- AssemblyScript Mappings (`mapping.ts`) - translates data from your datasources to the entities defined in the schema.
90
93
91
94
For a detailed breakdown on how to write your subgraph, check out [Creating a Subgraph](/developing/creating-a-subgraph/).
92
95
93
-
### 5. Deploy to your subgraph
96
+
### 5. Deploy Your Subgraph
94
97
95
98
Remember, deploying is not the same as publishing.
96
99
97
100
- When you deploy a subgraph, you push it to [Subgraph Studio](https://thegraph.com/studio/), where you can test, stage and review it.
98
101
- When you publish a subgraph, you are publishing it onchain to the decentralized network.
99
102
100
-
1. Once your subgraph is written, run the following commands:
103
+
1.Once your subgraph is written, run the following commands:
101
104
102
-
```sh
103
-
$ graph codegen
104
-
$ graph build
105
-
```
105
+
```sh
106
+
graph codegen
107
+
graph build
108
+
```
106
109
107
-
2. Authenticate and deploy your subgraph. The deploy key can be found on the Subgraph page in Subgraph Studio.
110
+
2.Authenticate and deploy your subgraph. The deploy key can be found on the Subgraph page in Subgraph Studio.
108
111
109
-
```sh
110
-
$ graph auth --studio <DEPLOY_KEY>
111
-
$ graph deploy --studio <SUBGRAPH_SLUG>
112
-
```
112
+
```sh
113
+
graph auth --studio <DEPLOY_KEY>
114
+
graph deploy --studio <SUBGRAPH_SLUG>
115
+
```
113
116
114
117
- The CLI will ask for a version label.
115
-
- It's strongly recommended to use [semver](https://semver.org/) for versioning like `0.0.1.` That said, you can choose any string as version such as: `v1, version1, asdf`.
118
+
- 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`, ect.
116
119
117
-
### 6. Review your subgraph
120
+
### 6. Review Your Subgraph
118
121
119
122
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:
120
123
@@ -125,46 +128,56 @@ If you’d like to examine your subgraph before publishing it to the network, yo
125
128
126
129

127
130
128
-
### 7. Publish Your Subgraph to The Graph
131
+
### 7. Publish Your Subgraph to The Graph Network
129
132
130
-
Publishing a subgraph to the decentralized network makes it available for [Curators](/network/curating/) to begin curating it and [Indexers](/network/indexing/) to index it.
133
+
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.
131
134
132
135
#### Publishing with Subgraph Studio
133
136
134
-
1. To publish your subgraph, click the publish button in the dashboard.
135
-
2. Select the network to which you would like to publish your subgraph.
136
-
- Subgraphs are published to Arbitrum One to take advantage of the [faster transaction speeds and lower gas costs](https://thegraph.com/docs/en/arbitrum/arbitrum-faq/).
137
+
1. To publish your subgraph, click the Publish button in the dashboard.
138
+
2. Select the network to which you would like to publish your subgraph.
137
139
138
140
#### Publishing from the CLI
139
141
140
-
As of version 0.73.0, you can also publish your subgraph with the [`graph-cli`](https://github.com/graphprotocol/graph-tooling/tree/main/packages/cli).
142
+
As of version 0.73.0, you can also publish your subgraph with the Graph CLI.
143
+
144
+
1. Open the `graph-cli`.
145
+
2. Use the following commands:
146
+
147
+
```sh
148
+
graph codegen && graph build
149
+
```
150
+
151
+
Then,
152
+
153
+
```sh
154
+
graph publish
155
+
```
141
156
142
-
1. Open the `graph-cli`.
143
-
2. Use the following commands: `graph codegen && graph build` then `graph publish`.
144
-
3. A window will open, allowing you to connect your wallet, add metadata, and deploy your finalized subgraph to a network of your choice.
157
+
3. A window will open, allowing you to connect your wallet, add metadata, and deploy your finalized subgraph to a network of your choice.
145
158
146
159

147
160
148
-
To customize your deployment see [publishing a subgraph](/publishing/publishing-a-subgraph/)
161
+
To customize your deployment, see [Publishing a Subgraph](/publishing/publishing-a-subgraph/).
149
162
150
163
#### Adding signal to your subgraph
151
164
152
-
1. To attract indexers to query your subgraph, you should add GRT curation signal to it.
165
+
1.To attract indexers to query your subgraph, you should add GRT curation signal to it.
153
166
154
-
- This action improves quality of service, reduces latency, and enhances network redundancy and availability for your subgraphs.
167
+
- This action improves quality of service, reduces latency, and enhances network redundancy and availability for your subgraphs.
155
168
156
-
2. If eligible for indexing rewards, Indexers receive GRT rewards based on the signaled amount.
169
+
2.If eligible for indexing rewards, Indexers receive GRT rewards based on the signaled amount.
157
170
158
-
- 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.
171
+
- 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.
159
172
160
173
To learn more about curation, read [Curating](/network/curating/).
161
174
162
-
To save on gas costs, you can curate your subgraph in the same transaction you publish it by selecting this button:
175
+
To save on gas costs, you can curate your subgraph in the same transaction you publish it by selecting this option:
0 commit comments