Skip to content

Commit 5a3dcfe

Browse files
authored
Polish The Graph doc (AstarNetwork#550)
* 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
1 parent 4152698 commit 5a3dcfe

File tree

5 files changed

+40
-78
lines changed

5 files changed

+40
-78
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ yarn-error.log*
2626
!.yarn/plugins
2727
!.yarn/sdks
2828
!.yarn/versions
29-
# .pnp.* # Comment for zero-install
29+
# .pnp.* # Comment for zero-install

docs/build/integrations/indexers/thegraph.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import Figure from '/src/components/figure'
88

99
## Overview: Why is The Graph needed?
1010

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+
1115
[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.
1216

1317
## Prerequisites
@@ -81,7 +85,16 @@ ethereum: 'shibuya:https://<IP address or domain>:<PORT>'
8185
# open docker-compose.yml
8286
nano docker-compose.yml
8387
# 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>'
8598
```
8699

87100
For example, if you are building a Graph node for Shiden, the entire `docker-compose.yml` now should appear as below:
Loading
Loading

docs/build/zkEVM/integrations/indexers/thegraph.md

+25-76
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,27 @@ sidebar_position: 1
55

66
import Figure from '/src/components/figure'
77

8+
<Figure src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph1-logo.jpg').default} width="100%" />
9+
810
# Overview
911

12+
:::note
13+
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+
1016
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.
1117

1218
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.
1319

1420
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.
1521

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.
1923

2024
## How do developers integrate The Graph?
2125

2226
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.
2327

24-
### Subgraph Overview
28+
## Subgraph Overview
2529

2630
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.
2731

@@ -63,59 +67,6 @@ After running the command, the tail end of the output should be similar to that
6367

6468
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.
6569

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>'
99-
RUST_LOG: info
100-
ipfs:
101-
image: ipfs/go-ipfs:v0.4.23
102-
ports:
103-
- '5001:5001'
104-
volumes:
105-
- ./data/ipfs:/data/ipfs
106-
postgres:
107-
image: postgres
108-
ports:
109-
- '5432:5432'
110-
command: ["postgres", "-cshared_preload_libraries=pg_stat_statements"]
111-
environment:
112-
POSTGRES_USER: graph-node
113-
POSTGRES_PASSWORD: let-me-in
114-
POSTGRES_DB: graph-node
115-
volumes:
116-
- ./data/postgres:/var/lib/postgresql/data
117-
```
118-
11970
### Running The Graph containers
12071

12172
Run the following command:
@@ -163,7 +114,7 @@ Once installed, the `graph init` command can be used to set up a new subgraph pr
163114

164115
### From An Existing Contract⁠
165116

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.
167118

168119
```js
169120
graph init \
@@ -176,13 +127,19 @@ graph init \
176127

177128
The `<SUBGRAPH_SLUG>` is the ID of your subgraph in Subgraph Studio, it can be found on your subgraph details page.
178129

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:
180131

181132
<Figure src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph11-initializesubgraph.png').default} width="50%" />
182133

134+
135+
:::note
136+
Astar zKatana network is referred to as `astar-zkevm-sepolia` and Astar zkEVM is referred to as `astar-zkevm` within `graph init` interactive mode.
137+
<Figure src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph14-astar-zkevm-networks.png').default} width="50%" />
138+
:::
139+
183140
### Add New dataSources To An Existing Subgraph
184141

185-
Since v0.31.0 the graph-cli supports adding new dataSources to an existing subgraph through the graph add command.
142+
Since v0.31.0 the graph-cli supports adding new dataSources to an existing subgraph through the `graph add` command.
186143

187144
```js
188145
graph add <address> [<subgraph-manifest default: "./subgraph.yaml">]
@@ -204,7 +161,7 @@ If true: the new dataSource should use existing eventHandlers & entities.
204161
If false: a new entity & event handler should be created with `${dataSourceName}{EventName}`.
205162
The contract address will be written to the networks.json for the relevant network.
206163

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.
208165

209166
### The Subgraph Manifest
210167

@@ -294,34 +251,26 @@ These ordering rules are subject to change.
294251

295252
## How to Define a Subgraph using Subgraph Studio
296253

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.
298255

299256
:::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.
301258
:::
302259

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:
304261

305262
<Figure caption="Connect your wallet" src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph2-connectwallet.png').default} width="100%" />
306263

307264
<Figure caption="Choose wallet" src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph3-connectwallet2.png').default} width="65%"/>
308265

309-
API keys are required to use subgraphs. Click on the **API Keys** tab and then create an API Key:
310-
311-
<Figure caption="Create API Key" src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph5-createfirstAPI.png').default} width="100%" />
312-
313-
<Figure caption="Choose an appropriate name" src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph6-createAPIkey.png').default} width="35%"/>
314-
315-
<Figure caption="Bonus for new users" src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph7-freequeries.png').default} width="35%"/>
316-
317-
<Figure caption="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.
318267

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'.
320269

321-
<Figure caption="Create Subgraph" src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph9-createsubgraph.png').default} width="35%"/>
270+
4. Add relevant details to your Subgraph.
322271

323272
<Figure caption="New subgraph details" src={require('/docs/build/zkEVM/integrations/indexers/img/thegraph10-subgraph.png').default} width="85%" />
324273

325-
At this point, the new subgraph is ready to initialize.
274+
At this point, the new subgraph is ready to initialize by following the instructions on the right-hand side.
326275

327276
For more information and advanced configuration, consult the [Graph Documentation](https://thegraph.com/docs/en/developing/creating-a-subgraph)

0 commit comments

Comments
 (0)