Skip to content

Commit ddf2d33

Browse files
Multichain ready (#294)
* Initial commit * Many fixes * Update pages/en/cookbook/quick-start.mdx Co-authored-by: Benoît Rouleau <[email protected]> * Update pages/en/cookbook/quick-start.mdx Co-authored-by: Benoît Rouleau <[email protected]> * Update pages/en/deploying/hosted-service.mdx Co-authored-by: Benoît Rouleau <[email protected]> * Update pages/en/deploying/hosted-service.mdx Co-authored-by: Benoît Rouleau <[email protected]> * Update pages/en/deploying/hosted-service.mdx Co-authored-by: Benoît Rouleau <[email protected]> * Update pages/en/developing/creating-a-subgraph.mdx Co-authored-by: Benoît Rouleau <[email protected]> * Update pages/en/developing/developer-faqs.mdx Co-authored-by: Benoît Rouleau <[email protected]> * Update pages/en/managing/deprecating-a-subgraph.mdx Co-authored-by: Benoît Rouleau <[email protected]> * Update pages/en/network-transition-faq.mdx Co-authored-by: Benoît Rouleau <[email protected]> * Update pages/en/network/overview.mdx Co-authored-by: Benoît Rouleau <[email protected]> * Fixes graph-node consistency work token -> work utility token * Final fixes * Latest changes * Small typo * Rewordings & fixing typos --------- Co-authored-by: Benoît Rouleau <[email protected]>
1 parent 93e9a5e commit ddf2d33

19 files changed

+103
-91
lines changed

website/pages/en/about.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ title: About The Graph
44

55
This page will explain what The Graph is and how you can get started.
66

7-
## What The Graph Is
7+
## What is The Graph?
88

9-
The Graph is a decentralized protocol for indexing and querying data from blockchains, starting with Ethereum. It makes it possible to query data that is difficult to query directly.
9+
The Graph is a decentralized protocol for indexing and querying blockchain data. The Graph makes it possible to query data that is difficult to query directly.
1010

1111
Projects with complex smart contracts like [Uniswap](https://uniswap.org/) and NFTs initiatives like [Bored Ape Yacht Club](https://boredapeyachtclub.com/) store data on the Ethereum blockchain, making it really difficult to read anything other than basic data directly from the blockchain.
1212

1313
In the case of Bored Ape Yacht Club, we can perform basic read operations on [the contract](https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#code) like 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, but more advanced real-world queries and operations like aggregation, search, relationships, and non-trivial filtering are not possible. For example, if we wanted to query for apes that are owned by a certain address, and filter by one of its characteristics, we would not be able to get that information by interacting directly with the contract itself.
1414

1515
To get this data, you would have to process every single [`transfer`](https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#code#L1746) event ever emitted, read the metadata from IPFS using the Token ID and IPFS hash, and then aggregate it. Even for these types of relatively simple questions, it would take **hours or even days** for a decentralized application (dapp) running in a browser to get an answer.
1616

17-
You could also build out your own server, process the transactions there, save them to a database, and build an API endpoint on top of it all in order to query the data. However, this option is resource intensive, needs maintenance, presents a single point of failure, and breaks important security properties required for decentralization.
17+
You could also build out your own server, process the transactions there, save them to a database, and build an API endpoint on top of it all in order to query the data. However, this option is [resource intensive](/network/benefits/), needs maintenance, presents a single point of failure, and breaks important security properties required for decentralization.
1818

1919
**Indexing blockchain data is really, really hard.**
2020

@@ -30,15 +30,15 @@ Once you have written a `subgraph manifest`, you use the Graph CLI to store the
3030

3131
This diagram gives more detail about the flow of data once a subgraph manifest has been deployed, dealing with Ethereum transactions:
3232

33-
![](/img/graph-dataflow.png)
33+
![A graphic explaining how The Graph uses Graph Node to serve queries to data consumers](/img/graph-dataflow.png)
3434

3535
The flow follows these steps:
3636

37-
1. A decentralized application adds data to Ethereum through a transaction on a smart contract.
37+
1. A dapp adds data to Ethereum through a transaction on a smart contract.
3838
2. The smart contract emits one or more events while processing the transaction.
3939
3. Graph Node continually scans Ethereum for new blocks and the data for your subgraph they may contain.
4040
4. Graph Node finds Ethereum events for your subgraph in these blocks and runs the mapping handlers you provided. The mapping is a WASM module that creates or updates the data entities that Graph Node stores in response to Ethereum events.
41-
5. The decentralized application queries the Graph Node for data indexed from the blockchain, using the node's [GraphQL endpoint](https://graphql.org/learn/). The Graph Node in turn translates the GraphQL queries into queries for its underlying data store in order to fetch this data, making use of the store's indexing capabilities. The decentralized application displays this data in a rich UI for end-users, which they use to issue new transactions on Ethereum. The cycle repeats.
41+
5. The dapp queries the Graph Node for data indexed from the blockchain, using the node's [GraphQL endpoint](https://graphql.org/learn/). The Graph Node in turn translates the GraphQL queries into queries for its underlying data store in order to fetch this data, making use of the store's indexing capabilities. The dapp displays this data in a rich UI for end-users, which they use to issue new transactions on Ethereum. The cycle repeats.
4242

4343
## Next Steps
4444

website/pages/en/cookbook/quick-start.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
title: Quick Start
33
---
44

5-
This guide will quickly take you through how to initialize, create, and deploy your subgraph on:
5+
This guide will quickly take you through how to initialize, create, and deploy your subgraph to the Subgraph Studio or the [hosted service](#hosted-service).
66

7-
- **Subgraph Studio** - used only for subgraphs that index **Ethereum mainnet**
8-
- **Hosted Service** - used for subgraphs that index **other networks** outside of Ethereum mainnnet (e.g. Binance, Matic, etc)
7+
Ensure that your subgraph will be indexing data from a [supported network](/developing/supported-networks).
98

109
## Subgraph Studio
1110

@@ -40,7 +39,7 @@ graph init --studio <SUBGRAPH_SLUG>
4039
The previous commands create a scaffold subgraph that you can use as a starting point for building your subgraph. When making changes to the subgraph, you will mainly work with three files:
4140

4241
- Manifest (subgraph.yaml) - The manifest defines what datasources your subgraphs will index.
43-
- Schema (schema.graphql) - The GraphQL schema defines what data you wish to retreive from the subgraph.
42+
- Schema (schema.graphql) - The GraphQL schema defines what data you wish to retrieve from the subgraph.
4443
- AssemblyScript Mappings (mapping.ts) - This is the code that translates data from your datasources to the entities defined in the schema.
4544

4645
For more information on how to write your subgraph, see [Creating a Subgraph](/developing/creating-a-subgraph).

website/pages/en/deploying/deploying-a-subgraph-to-hosted.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
title: Deploying a Subgraph to the Hosted Service
33
---
44

5-
This page explains how to deploy a subgraph to the Hosted Service. To deploy a subgraph you need to first install the [Graph CLI](https://github.com/graphprotocol/graph-cli). If you have not created a subgraph already, see [creating a subgraph](/developing/creating-a-subgraph).
5+
> If a network is not supported on the Hosted Service, you can run your own [graph-node](https://github.com/graphprotocol/graph-node) to index it.
66
7-
> If an EVM compatible chain is not supported on the Hosted Service, you can run your own [graph-node](https://github.com/graphprotocol/graph-node) to index it.
7+
This page explains how to deploy a subgraph to the Hosted Service. To deploy a subgraph you need to first install the [Graph CLI](https://github.com/graphprotocol/graph-cli). If you have not created a subgraph already, see [creating a subgraph](/developing/creating-a-subgraph).
88

99
## Create a Hosted Service account
1010

@@ -40,17 +40,19 @@ Deploying your subgraph will upload the subgraph files that you've built with `y
4040

4141
You deploy the subgraph by running `yarn deploy`
4242

43-
After deploying the subgraph, the Graph Explorer will switch to showing the synchronization status of your subgraph. Depending on the amount of data and the number of events that need to be extracted from historical Ethereum blocks, starting with the genesis block, syncing can take from a few minutes to several hours. The subgraph status switches to `Synced` once the Graph Node has extracted all data from historical blocks. The Graph Node will continue inspecting Ethereum blocks for your subgraph as these blocks are mined.
43+
After deploying the subgraph, the Graph Explorer will switch to showing the synchronization status of your subgraph. Depending on the amount of data and the number of events that need to be extracted from historical blocks, starting with the genesis block, syncing can take from a few minutes to several hours.
44+
45+
The subgraph status switches to `Synced` once the Graph Node has extracted all data from historical blocks. The Graph Node will continue inspecting blocks for your subgraph as these blocks are mined.
4446

4547
## Redeploying a Subgraph
4648

4749
When making changes to your subgraph definition, for example, to fix a problem in the entity mappings, run the `yarn deploy` command above again to deploy the updated version of your subgraph. Any update of a subgraph requires that Graph Node reindexes your entire subgraph, again starting with the genesis block.
4850

4951
If your previously deployed subgraph is still in status `Syncing`, it will be immediately replaced with the newly deployed version. If the previously deployed subgraph is already fully synced, Graph Node will mark the newly deployed version as the `Pending Version`, sync it in the background, and only replace the currently deployed version with the new one once syncing the new version has finished. This ensures that you have a subgraph to work with while the new version is syncing.
5052

51-
## Deploying the subgraph to multiple Ethereum networks
53+
## Deploying the subgraph to multiple networks
5254

53-
In some cases, you will want to deploy the same subgraph to multiple Ethereum networks without duplicating all of its code. The main challenge that comes with this is that the contract addresses on these networks are different.
55+
In some cases, you will want to deploy the same subgraph to multiple networks without duplicating all of its code. The main challenge that comes with this is that the contract addresses on these networks are different.
5456

5557
### Using graph-cli
5658

website/pages/en/deploying/hosted-service.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ title: What is the Hosted Service?
66
77
This section will walk you through deploying a subgraph to the [Hosted Service](https://thegraph.com/hosted-service/).
88

9-
If you don't have an account on the Hosted Service, you can sign up with your Github account. Once you authenticate, you can start creating subgraphs through the UI and deploying them from your terminal. The Hosted Service supports a number of evm-compatible networks, such as Polygon, Gnosis Chain, BNB Chain, Optimism and Arbitrum. For a comprehensive list see [Supported Networks](https://thegraph.com/docs/en/deploying/deploying-a-subgraph-to-hosted/)
9+
If you don't have an account on the Hosted Service, you can sign up with your GitHub account. Once you authenticate, you can start creating subgraphs through the UI and deploying them from your terminal. The Hosted Service supports a number of networks, such as Polygon, Gnosis Chain, BNB Chain, Optimism, Arbitrum, and more.
10+
11+
For a comprehensive list, see [Supported Networks](/developing/supported-networks/#hosted-service).
1012

1113
## Create a Subgraph
1214

1315
First follow the instructions [here](/developing/defining-a-subgraph) to install the Graph CLI. Create a subgraph by passing in `graph init --product hosted-service`
1416

1517
### From an Existing Contract
1618

17-
If you already have a smart contract deployed to Ethereum mainnet or one of the testnets, bootstrapping a new subgraph from this contract can be a good way to get started on the Hosted Service.
19+
If you already have a smart contract deployed to your network of choice, bootstrapping a new subgraph from this contract can be a good way to get started on the Hosted Service.
1820

1921
You can use this command to create a subgraph that indexes all events from an existing contract. This will attempt to fetch the contract ABI from [Etherscan](https://etherscan.io/).
2022

@@ -32,7 +34,7 @@ Additionally, you can use the following optional arguments. If the ABI cannot be
3234
--abi <FILE> \
3335
```
3436

35-
The `<GITHUB_USER>` in this case is your GitHub user or organization name, `<SUBGRAPH_NAME>` is the name for your subgraph, and `<DIRECTORY>` is the optional name of the directory where graph init will put the example subgraph manifest. The `<CONTRACT_ADDRESS>` is the address of your existing contract. `<ETHEREUM_NETWORK>` is the name of the Ethereum network that the contract lives on. `<FILE>` is a local path to a contract ABI file. **Both --network and --abi are optional.**
37+
The `<GITHUB_USER>` in this case is your GitHub user or organization name, `<SUBGRAPH_NAME>` is the name for your subgraph, and `<DIRECTORY>` is the optional name of the directory where `graph init` will put the example subgraph manifest. The `<CONTRACT_ADDRESS>` is the address of your existing contract. `<ETHEREUM_NETWORK>` is the name of the network that the contract lives on. `<FILE>` is a local path to a contract ABI file. **Both `--network` and `--abi` are optional.**
3638

3739
### From an Example Subgraph
3840

website/pages/en/deploying/subgraph-studio.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The best part! When you first create a subgraph, you’ll be directed to fill ou
4444

4545
The Graph Network is not yet able to support all of the data-sources & features available on the Hosted Service. In order to be supported by Indexers on the network, subgraphs must:
4646

47-
- Index mainnet Ethereum
47+
- Index a [supported network](/developing/supported-networks)
4848
- Must not use any of the following features:
4949
- ipfs.cat & ipfs.map
5050
- Non-fatal errors
@@ -64,13 +64,17 @@ If you’d like to test your subgraph before publishing it to the network, you c
6464

6565
## Publish your Subgraph in Subgraph Studio
6666

67-
You’ve made it this far - congrats! Publishing your subgraph means that an IPFS hash was generated when you deployed the subgraph within the CLI and is stored in the network’s Ethereum smart contracts. In order to publish your subgraph successfully, you’ll need to go through the following steps outlined in this [blog](https://thegraph.com/blog/building-with-subgraph-studio). Check out the video overview below as well:
67+
You’ve made it this far - congrats!
68+
69+
In order to publish your subgraph successfully, you’ll need to go through the following steps outlined in this [blog](https://thegraph.com/blog/building-with-subgraph-studio).
70+
71+
Check out the video overview below as well:
6872

6973
<VideoEmbed youtube="HfDgC2oNnwo" />
7074

71-
Remember, while you’re going through your publishing flow, you’ll be able to push to either mainnet or Goerli, the testnet we support. If you’re a first-time subgraph developer, we highly suggest you start with publishing to Goerli, which is free to do. This will allow you to see how the subgraph will work in The Graph Explorer and will allow you to test curation elements.
75+
Remember, while you’re going through your publishing flow, you’ll be able to push to either mainnet or Goerli. If you’re a first-time subgraph developer, we highly suggest you start with publishing to Goerli, which is free to do. This will allow you to see how the subgraph will work in The Graph Explorer and will allow you to test curation elements.
7276

73-
You’ll only be able to index data from mainnet (even if your subgraph was published to a testnet) because only subgraphs that are indexing mainnet data can be published to the network. This is because Indexers need to submit mandatory Proof of Indexing records as of a specific block hash. Because publishing a subgraph is an action taken on-chain, remember that the transaction can take up to a few minutes to go through. Any address you use to publish the contract will be the only one able to publish future versions. Choose wisely!
77+
Indexers need to submit mandatory Proof of Indexing records as of a specific block hash. Because publishing a subgraph is an action taken on-chain, remember that the transaction can take up to a few minutes to go through. Any address you use to publish the contract will be the only one able to publish future versions. Choose wisely!
7478

7579
Subgraphs with curation signal are shown to Indexers so that they can be indexed on the decentralized network. You can publish subgraphs and signal in one transaction, which allows you to mint the first curation signal on the subgraph and saves on gas costs. By adding your signal to the signal later provided by Curators, your subgraph will also have a higher chance of ultimately serving queries.
7680

website/pages/en/developing/creating-a-subgraph.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ yarn global add @graphprotocol/graph-cli
3636
npm install -g @graphprotocol/graph-cli
3737
```
3838

39-
Once installed, the `graph init` command can be used to set up a new subgraph project, either from an existing contract on any of the public Ethereum networks or from an example subgraph. This command can be used to create a subgraph on the Subgraph Studio by passing in `graph init --product subgraph-studio`. If you already have a smart contract deployed to Ethereum mainnet or one of the testnets, bootstrapping a new subgraph from that contract can be a good way to get started.
39+
Once installed, the `graph init` command can be used to set up a new subgraph project, either from an existing contract or from an example subgraph. This command can be used to create a subgraph on the Subgraph Studio by passing in `graph init --product subgraph-studio`. If you already have a smart contract deployed to your preferred network, bootstrapping a new subgraph from that contract can be a good way to get started.
4040

4141
## From An Existing Contract
4242

@@ -475,7 +475,7 @@ Supported algorithms for ordering results:
475475

476476
## Writing Mappings
477477

478-
The mappings transform the Ethereum data your mappings are sourcing into entities defined in your schema. Mappings are written in a subset of [TypeScript](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html) called [AssemblyScript](https://github.com/AssemblyScript/assemblyscript/wiki) which can be compiled to WASM ([WebAssembly](https://webassembly.org/)). AssemblyScript is stricter than normal TypeScript, yet provides a familiar syntax.
478+
The mappings take data from a particular source and transform it into entities that are defined within your schema. Mappings are written in a subset of [TypeScript](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html) called [AssemblyScript](https://github.com/AssemblyScript/assemblyscript/wiki) which can be compiled to WASM ([WebAssembly](https://webassembly.org/)). AssemblyScript is stricter than normal TypeScript, yet provides a familiar syntax.
479479

480480
For each event handler that is defined in `subgraph.yaml` under `mapping.eventHandlers`, create an exported function of the same name. Each handler must accept a single parameter called `event` with a type corresponding to the name of the event which is being handled.
481481

@@ -564,7 +564,9 @@ Code generation does not check your mapping code in `src/mapping.ts`. If you wan
564564

565565
## Data Source Templates
566566

567-
A common pattern in Ethereum smart contracts is the use of registry or factory contracts, where one contract creates, manages, or references an arbitrary number of other contracts that each have their own state and events. The addresses of these sub-contracts may or may not be known upfront and many of these contracts may be created and/or added over time. This is why, in such cases, defining a single data source or a fixed number of data sources is impossible and a more dynamic approach is needed: _data source templates_.
567+
A common pattern in EVM-compatible smart contracts is the use of registry or factory contracts, where one contract creates, manages, or references an arbitrary number of other contracts that each have their own state and events.
568+
569+
The addresses of these sub-contracts may or may not be known upfront and many of these contracts may be created and/or added over time. This is why, in such cases, defining a single data source or a fixed number of data sources is impossible and a more dynamic approach is needed: _data source templates_.
568570

569571
### Data Source for the Main Contract
570572

website/pages/en/developing/developer-faqs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ dataSource.address()
7979

8080
### 15. Do you support block and call handlers on Goerli?
8181

82-
Yes. Goerli supports block handlers, call handlers and event handlers. It should be noted that event handlers are far more performant than the other two handlers, and they are supported on every EVM network.
82+
Yes. Goerli supports block handlers, call handlers and event handlers. It should be noted that event handlers are far more performant than the other two handlers, and they are supported on every EVM-compatible network.
8383

8484
### 16. Can I import ethers.js or other JS libraries into my subgraph mappings?
8585

0 commit comments

Comments
 (0)