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/about.mdx
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,17 @@ title: About The Graph
4
4
5
5
This page will explain what The Graph is and how you can get started.
6
6
7
-
## What The Graph Is
7
+
## What is The Graph?
8
8
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.
10
10
11
11
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.
12
12
13
13
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.
14
14
15
15
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.
16
16
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.
18
18
19
19
**Indexing blockchain data is really, really hard.**
20
20
@@ -30,15 +30,15 @@ Once you have written a `subgraph manifest`, you use the Graph CLI to store the
30
30
31
31
This diagram gives more detail about the flow of data once a subgraph manifest has been deployed, dealing with Ethereum transactions:
32
32
33
-

33
+

34
34
35
35
The flow follows these steps:
36
36
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.
38
38
2. The smart contract emits one or more events while processing the transaction.
39
39
3. Graph Node continually scans Ethereum for new blocks and the data for your subgraph they may contain.
40
40
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.
Copy file name to clipboardExpand all lines: website/pages/en/cookbook/quick-start.mdx
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,9 @@
2
2
title: Quick Start
3
3
---
4
4
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).
6
6
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).
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:
41
40
42
41
- 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.
44
43
- AssemblyScript Mappings (mapping.ts) - This is the code that translates data from your datasources to the entities defined in the schema.
45
44
46
45
For more information on how to write your subgraph, see [Creating a Subgraph](/developing/creating-a-subgraph).
Copy file name to clipboardExpand all lines: website/pages/en/deploying/deploying-a-subgraph-to-hosted.mdx
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,9 @@
2
2
title: Deploying a Subgraph to the Hosted Service
3
3
---
4
4
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.
6
6
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).
8
8
9
9
## Create a Hosted Service account
10
10
@@ -40,17 +40,19 @@ Deploying your subgraph will upload the subgraph files that you've built with `y
40
40
41
41
You deploy the subgraph by running `yarn deploy`
42
42
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.
44
46
45
47
## Redeploying a Subgraph
46
48
47
49
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.
48
50
49
51
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.
50
52
51
-
## Deploying the subgraph to multiple Ethereum networks
53
+
## Deploying the subgraph to multiple networks
52
54
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.
Copy file name to clipboardExpand all lines: website/pages/en/deploying/hosted-service.mdx
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,17 @@ title: What is the Hosted Service?
6
6
7
7
This section will walk you through deploying a subgraph to the [Hosted Service](https://thegraph.com/hosted-service/).
8
8
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).
10
12
11
13
## Create a Subgraph
12
14
13
15
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`
14
16
15
17
### From an Existing Contract
16
18
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.
18
20
19
21
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/).
20
22
@@ -32,7 +34,7 @@ Additionally, you can use the following optional arguments. If the ABI cannot be
32
34
--abi <FILE> \
33
35
```
34
36
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.**
Copy file name to clipboardExpand all lines: website/pages/en/deploying/subgraph-studio.mdx
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ The best part! When you first create a subgraph, you’ll be directed to fill ou
44
44
45
45
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:
46
46
47
-
- Index mainnet Ethereum
47
+
- Index a [supported network](/developing/supported-networks)
48
48
- Must not use any of the following features:
49
49
- ipfs.cat & ipfs.map
50
50
- Non-fatal errors
@@ -64,13 +64,17 @@ If you’d like to test your subgraph before publishing it to the network, you c
64
64
65
65
## Publish your Subgraph in Subgraph Studio
66
66
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:
68
72
69
73
<VideoEmbedyoutube="HfDgC2oNnwo" />
70
74
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.
72
76
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!
74
78
75
79
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.
Copy file name to clipboardExpand all lines: website/pages/en/developing/creating-a-subgraph.mdx
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ yarn global add @graphprotocol/graph-cli
36
36
npm install -g @graphprotocol/graph-cli
37
37
```
38
38
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.
40
40
41
41
## From An Existing Contract
42
42
@@ -475,7 +475,7 @@ Supported algorithms for ordering results:
475
475
476
476
## Writing Mappings
477
477
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.
479
479
480
480
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.
481
481
@@ -564,7 +564,9 @@ Code generation does not check your mapping code in `src/mapping.ts`. If you wan
564
564
565
565
## Data Source Templates
566
566
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_.
Copy file name to clipboardExpand all lines: website/pages/en/developing/developer-faqs.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,7 @@ dataSource.address()
79
79
80
80
### 15. Do you support block and call handlers on Goerli?
81
81
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.
83
83
84
84
### 16. Can I import ethers.js or other JS libraries into my subgraph mappings?
0 commit comments