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
+70-30Lines changed: 70 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ By the end, you'll have:
8
8
9
9
- Initialized a Subgraph from a smart contract
10
10
- Deployed it to Subgraph Studio for testing
11
-
- Published to The Graph Network for decentralized indexing
11
+
- Published to The Graph Network for decentralized indexing using Studio or CLI
12
12
13
13
## Prerequisites
14
14
@@ -51,7 +51,7 @@ graph --version
51
51
52
52
> You can find commands for your specific Subgraph in [Subgraph Studio](https://thegraph.com/studio/).
53
53
54
-
The following command initializes your Subgraph from an existing contract and indexes events:
54
+
Initialize your Subgraph from an existing contract:
55
55
56
56
```sh
57
57
graph init
@@ -63,7 +63,7 @@ When you initialize your Subgraph, the CLI will ask you for the following inform
63
63
-**Subgraph slug**: Create a name for your Subgraph. Your Subgraph slug is an identifier for your Subgraph.
64
64
-**Directory**: Choose a directory to create your Subgraph in.
65
65
-**Ethereum network** (optional): You may need to specify which EVM-compatible network your Subgraph will be indexing data from.
66
-
-**Contract address**: Locate the smart contract address you’d like to query data from.
66
+
-**Contract address**: Locate the smart contract address you'd like to query data from.
67
67
-**ABI**: If the ABI is not auto-populated, you will need to input it manually as a JSON file.
68
68
-**Start Block**: You should input the start block where the contract was deployed to optimize Subgraph indexing of blockchain data.
69
69
-**Contract Name**: Input the name of your contract.
@@ -76,67 +76,107 @@ See the following screenshot for an example of what to expect when initializing
76
76
77
77
### 4. Edit your Subgraph
78
78
79
-
When making changes to the Subgraph, you will mainly work with three files:
79
+
When making changes to the Subgraph, you will primarily work with three files:
80
80
81
-
- Manifest (`subgraph.yaml`) - defines what data sources your Subgraph will index.
82
-
- Schema (`schema.graphql`) - defines what data you wish to retrieve from the Subgraph.
83
-
- AssemblyScript Mappings (`mapping.ts`) - translates data from your data sources to the entities defined in the schema.
81
+
- Manifest (`subgraph.yaml`): Defines what data sources your Subgraph will index.
82
+
- Schema (`schema.graphql`): Defines what data you wish to retrieve from the Subgraph.
83
+
- AssemblyScript Mappings (`mapping.ts`): Translates data from your data sources to the entities defined in the schema.
84
84
85
-
For a detailed breakdown on how to write your Subgraph, check out[Creating a Subgraph](/developing/creating-a-subgraph/).
85
+
For a detailed breakdown on how to write your Subgraph, refer to[Creating a Subgraph](/subgraphs/developing/creating/starting-your-subgraph/).
86
86
87
-
### 5. Deploy your Subgraph
87
+
##Path 1: Studio Approach
88
88
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.
89
+
### 5. Build your Subgraph
90
+
91
+
Run the following:
92
+
93
+
```sh
94
+
graph codegen && graph build
95
+
```
90
96
91
-
Once your Subgraph is written, run the following commands:
97
+
### 6. Deploy your Subgraph to Subgraph Studio
92
98
93
-
```sh
94
-
graph codegen && graph build
95
-
```
99
+
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.
96
100
97
-
Authenticate and deploy your Subgraph. The deploy key can be found on the Subgraph's page in Subgraph Studio.
101
+
> [!IMPORTANT] You do not need to use Subgraph Studio to publish your Subgraph to The Graph Network. Studio is only required for testing and staging your Subgraph prior to publishing.
102
+
103
+
1. Get your deploy key from the Subgraph page in Studio
If you’d like to test your Subgraph before publishing it, you can use [Subgraph Studio](https://thegraph.com/studio/) to do the following:
116
+
```sh
117
+
graph deploy <SUBGRAPH_SLUG>
118
+
```
119
+
120
+
### 7. Review in Studio
121
+
122
+
Use the Studio to:
111
123
112
124
- Run a sample query.
113
125
- Analyze your Subgraph in the dashboard to check information.
114
126
- Check the logs on the dashboard to see if there are any errors with your Subgraph. The logs of an operational Subgraph will look like this:
115
127
116
128

117
129
118
-
### 7. Publish your Subgraph to The Graph Network
130
+
### 8. Publish to The Graph Network
119
131
120
132
When your Subgraph is ready for a production environment, you can publish it to the decentralized network. Publishing is an onchain action that does the following:
121
133
122
134
- It makes your Subgraph available to be indexed by the decentralized [Indexers](/indexing/overview/) on The Graph Network.
123
135
- It removes rate limits and makes your Subgraph publicly searchable and queryable in [Graph Explorer](https://thegraph.com/explorer/).
124
136
- It makes your Subgraph available for [Curators](/resources/roles/curating/) to add curation signal.
125
137
126
-
To publish your Subgraph, click the Publish button in the dashboard and select your network.
138
+
1. Click **Publish** in Studio
139
+
2. Select network
140
+
3. (Recommended) Add curation during the same transaction to save on gas costs: 
127
141
128
142

129
143
130
-
> It is recommended that you curate your own Subgraph with at least 3,000 GRT to incentivize indexing.
144
+
> Curation with 3,000+ GRT is recommended to incentivize indexing.
145
+
146
+
## Path 2: CLI Approach
147
+
148
+
1. Open the `graph-cli`.
149
+
2. Run the following commands to build and publish your Subgraph: `graph codegen && graph build` then `graph publish`.
150
+
3. A browser window will prompt you to connect your wallet, add metadata, and publish your Subgraph to the network of your choice.
151
+
152
+

131
153
132
-
To save on gas costs, you can curate your Subgraph in the same transaction you publish it by selecting this option:
154
+
### Custom Options
155
+
156
+
You can customize the deployment by uploading to a specific IPFS node and using additional flags:
> [!NOTE] Add GRT signal to your Subgraph to incentivize Indexers to query your Subgraph. Refer to [Adding Signal](developing/publishing/publishing-a-subgraph/#adding-signal-to-your-subgraph) for specifics.
135
175
136
-
### 8. Query your Subgraph
176
+
### Final Step: Query your Subgraph
137
177
138
-
You now have access to 100,000 free queries per month with your Subgraph on The Graph Network!
178
+
After publishing, access your Subgraph's Query URL from [Graph Explorer](https://thegraph.com/explorer/). You can query your Subgraph by sending GraphQL queries to its Query URL, which you can find by clicking the Query button.
139
179
140
-
You can query your Subgraph by sending GraphQL queries to its Query URL, which you can find by clicking the Query button.
180
+
You get access to 100,000 free queries/month with your Subgraph on The Graph Network.
141
181
142
-
For more information about querying data from your Subgraph, read [Querying The Graph](/subgraphs/querying/introduction/).
182
+
Refer to [Querying The Graph](/subgraphs/querying/introduction/) to structure GraphQL queries.
0 commit comments