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
* polish the graph doc
remove reference to hosted service
* Update thegraph.md
* add video links
* reflect new updates in Subgraph Studio, add zkEVM
* Update .gitignore
Copy file name to clipboardexpand all lines: docs/build/integrations/indexers/thegraph.md
+14-1
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,10 @@ import Figure from '/src/components/figure'
8
8
9
9
## Overview: Why is The Graph needed?
10
10
11
+
:::note
12
+
The Graph team have prepared a highly informative video featuring an overview of the Graph protocol along with some hands-on examples you can try [here.](https://youtu.be/GSdORXxmqz0) This video covers everything you need to know to build support for The Graph into your full stack application, and create subgraphs to query the relevant data.
13
+
:::
14
+
11
15
[The Graph](https://thegraph.com/en) is a permissionless and decentralized protocol for indexing and querying data from blockchains. It makes querying fast, reliable, and secure, and allows anyone to build and publish application programming interfaces (APIs) called subgraphs, which act as intermediaries; allowing applications to communicate with one another.
12
16
13
17
## Prerequisites
@@ -81,7 +85,16 @@ ethereum: 'shibuya:https://<IP address or domain>:<PORT>'
81
85
# open docker-compose.yml
82
86
nano docker-compose.yml
83
87
# modify file and save
84
-
ethereum: 'zkatana:https://<IP address or domain>:<PORT>'
88
+
ethereum: 'astar-zkevm-sepolia:https://<IP address or domain>:<PORT>'
89
+
```
90
+
91
+
### Astar zkEVM
92
+
93
+
```sh
94
+
# open docker-compose.yml
95
+
nano docker-compose.yml
96
+
# modify file and save
97
+
ethereum: 'astar-zkevm:https://<IP address or domain>:<PORT>'
85
98
```
86
99
87
100
For example, if you are building a Graph node for Shiden, the entire `docker-compose.yml` now should appear as below:
The Graph team have prepared a highly informative video featuring an overview of the Graph protocol along with some hands-on examples you can try [here.](https://youtu.be/GSdORXxmqz0) This video covers everything you need to know to build support for The Graph into your full stack application, and create subgraphs to query the relevant data.
14
+
:::
15
+
10
16
The Graph is a decentralized protocol for indexing and querying blockchain data that makes it possible to query historical data that is difficult to query from smart contracts directly.
11
17
12
18
Projects with complex smart contracts such as Uniswap and NFT projects like Bored Ape Yacht Club store data on the Ethereum blockchain, making it difficult to read anything but the most basic information.
13
19
14
20
In the case of Bored Ape Yacht Club, it's possible to perform basic read operations on the contract such as getting the owner of a certain Ape, getting the content URI of an Ape based on their ID, or the total supply, as these read operations are programmed directly into the smart contract. More advanced real-world queries and operations like aggregation, search, relationships, and non-trivial filtering however are *not possible.* For example, if we would like to query all Apes owned by a certain address and filter results by one of its characteristics, we cannot rely on the contract itself; it cannot provide historical information.
15
21
16
-
To obtain this kind of data, we would need to process every transfer event ever emitted from the BAYC smart contract, read the metadata from IPFS using the Token ID and IPFS hash, and then aggregate all the results. Put simply, to answer these kinds of (relatively) simple questions, it would take *hours* or even *days* for a decentralized application running in a browser to obtain a result.
17
-
18
-
As a solution, a server could be used to process the transactions and save them to a database, and then an API endpoint can be configured on top to query the data. However, this would open up a whole new can of worms, which is why The Graph exists.
22
+
To obtain this kind of data, we would need to process every transfer event ever emitted from the BAYC smart contract, read the metadata from IPFS using the Token ID and IPFS hash, and then aggregate all the results. Put simply, to answer these kinds of (relatively) simple questions, it would take *hours* or even *days* for a decentralized application running in a browser to obtain a result, which is why The Graph exists - to make these kinds of queries simpler.
19
23
20
24
## How do developers integrate The Graph?
21
25
22
26
Developers can either run a standalone Graph node and define their own subgraph(s), or choose a subgraph that is publicly available on the Graph's decentralized network. The Graph processes subgraphs and makes the data accessible through GraphQL, a popular query language.
23
27
24
-
###Subgraph Overview
28
+
## Subgraph Overview
25
29
26
30
A subgraph is essentially a definition created by a developer that specifies which data The Graph should index from the blockchain, and how it should be stored.
27
31
@@ -63,59 +67,6 @@ After running the command, the tail end of the output should be similar to that
63
67
64
68
Once everything is set up, you will need to modify the "Ethereum environment" inside the `docker-compose.yml` file, so that the Graph node points to the endpoint of the RPC that you are connecting with. Note that the `setup.sh` file detects the RPC's Host IP and writes its value, so you'll need to modify it accordingly.
65
69
66
-
### zKatana specific setup
67
-
68
-
```sh
69
-
# open docker-compose.yml
70
-
nano docker-compose.yml
71
-
72
-
# modify file and save
73
-
ethereum: 'zkatana:https://<IP address or domain>:<PORT>'
74
-
```
75
-
76
-
The entire `docker-compose.yml` should appear as below:
77
-
78
-
```yaml
79
-
version: '3'
80
-
services:
81
-
graph-node:
82
-
image: graphprotocol/graph-node
83
-
ports:
84
-
- '8000:8000'
85
-
- '8001:8001'
86
-
- '8020:8020'
87
-
- '8030:8030'
88
-
- '8040:8040'
89
-
depends_on:
90
-
- ipfs
91
-
- postgres
92
-
environment:
93
-
postgres_host: postgres
94
-
postgres_user: graph-node
95
-
postgres_pass: let-me-in
96
-
postgres_db: graph-node
97
-
ipfs: 'ipfs:5001'
98
-
ethereum: 'zkatana:https://<IP address or DOMAIN>:<PORT>'
@@ -163,7 +114,7 @@ Once installed, the `graph init` command can be used to set up a new subgraph pr
163
114
164
115
### From An Existing Contract
165
116
166
-
The following command creates a subgraph that indexes all events of an existing contract. It attempts to fetch the contract ABI from Etherscan and falls back to requesting a local file path.
117
+
The following command creates a subgraph that indexes all events of an existing contract. It attempts to fetch the contract ABI from Etherscan and fails back to requesting a local file path.
167
118
168
119
```js
169
120
graph init \
@@ -176,13 +127,19 @@ graph init \
176
127
177
128
The `<SUBGRAPH_SLUG>` is the ID of your subgraph in Subgraph Studio, it can be found on your subgraph details page.
178
129
179
-
If any of the optional arguments are missing, it takes you through an interactive mode, shown below:
130
+
If any of the optional arguments are missing, `graph init` will fail back to interactive mode, shown below:
@@ -204,7 +161,7 @@ If true: the new dataSource should use existing eventHandlers & entities.
204
161
If false: a new entity & event handler should be created with `${dataSourceName}{EventName}`.
205
162
The contract address will be written to the networks.json for the relevant network.
206
163
207
-
Note: When using the interactive cli, after successfully running graph init, you'll be prompted to add a new dataSource.
164
+
Note: When using the interactive cli, after successfully running `graph init`, you'll be prompted to add a new dataSource.
208
165
209
166
### The Subgraph Manifest
210
167
@@ -294,34 +251,26 @@ These ordering rules are subject to change.
294
251
295
252
## How to Define a Subgraph using Subgraph Studio
296
253
297
-
If you are using The Graph's hosted service or Subgraph Studio, there is no need to spin up a standalone Graph node. After creating your account you can jump straight into defining a subgraph.
254
+
If you are using The Graph's Subgraph Studio, there is no need to spin up a standalone Graph node. After creating your account you can jump straight into defining a subgraph.
298
255
299
256
:::note
300
-
In order to use your subgraph with the Graph's hosted services, you will need to create an API key. It is also recommended that you [add signal](https://thegraph.com/docs/en/network/curating/#how-to-signal) to your subgraph with at least 10,000 GRT.
257
+
In order to use your subgraph with the Graph's decentralized network services, you will need to create an API key. It is also recommended that you [add signal](https://thegraph.com/docs/en/network/curating/#how-to-signal) to your subgraph with at least 10,000 GRT.
301
258
:::
302
259
303
-
Login to [Subgraph Studio](https://thegraph.com/studio/) with your Github account, and connect your wallet:
260
+
1.Login to [Subgraph Studio](https://thegraph.com/studio/) with your Github account, and connect your wallet:
304
261
305
262
<Figurecaption="Connect your wallet"src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph2-connectwallet.png').default}width="100%" />
API keys are required to use subgraphs. Click on the **API Keys** tab and then create an API Key:
310
-
311
-
<Figurecaption="Create API Key"src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph5-createfirstAPI.png').default}width="100%" />
312
-
313
-
<Figurecaption="Choose an appropriate name"src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph6-createAPIkey.png').default}width="35%"/>
314
-
315
-
<Figurecaption="Bonus for new users"src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph7-freequeries.png').default}width="35%"/>
316
-
317
-
<Figurecaption="The API Keys tab"src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph8-subgraphstudio.png').default}width="100%" />
266
+
2. API keys are required to use subgraphs. Click on the **API Keys** tab and then create an API Key.
318
267
319
-
Now, return to the **My Subgraphs** tab and create a subgraph. In this example we are using Ethereum Goerli testnet, but you should be able to choose zKatana testnet:
268
+
3. Return to **My Dashboard** tab and click 'Create a Subgraph'.
0 commit comments