-
Notifications
You must be signed in to change notification settings - Fork 155
About The Graph Update #929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c61f330
About Update
idalithb 2c2a131
More edits
idalithb 8f7b831
small edit
idalithb 4b772cd
Update website/src/pages/en/about.mdx
idalithb 4c56730
Update website/src/pages/en/about.mdx
idalithb 9f82806
Update website/src/pages/en/about.mdx
idalithb 918f063
Update website/src/pages/en/about.mdx
idalithb d2a4e4c
Update website/src/pages/en/about.mdx
idalithb c086c49
Update website/src/pages/en/about.mdx
idalithb 0dff9b4
Update website/src/pages/en/about.mdx
idalithb 684820c
Update website/src/pages/en/about.mdx
idalithb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,55 @@ | ||
--- | ||
title: About The Graph | ||
description: This page summarizes the core concepts and basics of The Graph Network. | ||
--- | ||
|
||
## What is The Graph? | ||
## Explanation | ||
|
||
The Graph is a powerful decentralized protocol that enables seamless querying and indexing of blockchain data. It simplifies the complex process of querying blockchain data, making dapp development faster and easier. | ||
### What is The Graph? | ||
|
||
## Understanding the Basics | ||
The Graph is a decentralized protocol for indexing and querying blockchain data. Its suite includes [Subgraphs](/en/subgraphs/developing/subgraphs/), [Substreams](/en/substreams/introduction/), [Token API BETA](/en/token-api/quick-start/), and tools like [Graph Explorer](/en/subgraphs/explorer/) and [Subgraph Studio](/en/subgraphs/developing/deploying/using-subgraph-studio/). | ||
|
||
Projects with complex smart contracts such as [Uniswap](https://uniswap.org/) and NFTs initiatives like [Bored Ape Yacht Club](https://boredapeyachtclub.com/) store data on the Ethereum blockchain, making it very difficult to read anything other than basic data directly from the blockchain. | ||
The Graph supports [90+ blockchains](/en/supported-networks/), enhancing dapp development and data retrieval. | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### Challenges Without The Graph | ||
### Why is Blockchain Data Hard to Query? | ||
|
||
In the case of the example listed above, Bored Ape Yacht Club, you can perform basic read operations on [the contract](https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#code). You can read the owner of a certain Ape, read the content URI of an Ape based on their ID, or read the total supply. | ||
Reading onchain data from the blockchain (e.g., ownership history, metadata, relationships between assets) typically requires processing smart contract events, parsing metadata from IPFS, and aggregating data manually. This is very slow, complex, and resource-intensive. | ||
|
||
- This can be done because these read operations are programmed directly into the smart contract itself. However, more advanced, specific, and real-world queries and operations like aggregation, search, relationships, and non-trivial filtering, **are not possible**. | ||
## Solution | ||
|
||
- For instance, if you want to inquire about Apes owned by a specific address and refine your search based on a particular characteristic, you would not be able to obtain that information by directly interacting with the contract itself. | ||
### How The Graph Solves This | ||
|
||
- To get more 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. | ||
The Graph simplifies the complex process of retrieving blockchain data through a global, decentralized network of Indexers that index Subgraphs. This infrastructure facilitates efficient, censorship-resistant query handling, allowing developers to build applications using blockchain data without the hassle of managing servers or custom indexing. | ||
|
||
### Why is this a problem? | ||
Each Subgraph defines: | ||
|
||
It would take **hours or even days** for a decentralized application (dapp) running in a browser to get an answer to these simple questions. | ||
- Which smart contracts to watch | ||
- Which events to extract | ||
- How to map event data into a queryable format using [GraphQL](https://graphql.org/learn/) | ||
|
||
Alternatively, you have the option to set up your own server, process the transactions, store them in a database, and create an API endpoint to query the data. However, this option is [resource intensive](/resources/benefits/), needs maintenance, presents a single point of failure, and breaks important security properties required for decentralization. | ||
### [Building a Subgraph](/en/subgraphs/developing/creating/starting-your-subgraph/) | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Blockchain properties, such as finality, chain reorganizations, and uncled blocks, add complexity to the process, making it time-consuming and conceptually challenging to retrieve accurate query results from blockchain data. | ||
1. Define a [Subgraph Manifest](/en/subgraphs/developing/creating/subgraph-manifest/) with data sources and mappings. | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
2. Use [Graph CLI](https://github.com/graphprotocol/graph-tooling/tree/main/packages/cli) to deploy the manifest to IPFS. | ||
3. An [Indexer](/en/indexing/overview/) picks it up and starts indexing Ethereum blocks. | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
4. Data becomes queryable via a [GraphQL endpoint](/en/subgraphs/querying/graphql-api/). | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## The Graph Provides a Solution | ||
### Data Flow Overview | ||
|
||
The Graph solves this challenge with a decentralized protocol that indexes and enables the efficient and high-performance querying of blockchain data. These APIs (indexed "Subgraphs") can then be queried with a standard GraphQL API. | ||
1. A dapp triggers a transaction on Ethereum by interacting with a smart contract. | ||
|
||
Today, there is a decentralized protocol that is backed by the open source implementation of [Graph Node](https://github.com/graphprotocol/graph-node) that enables this process. | ||
2. As the transaction is processed, the smart contract emits one or more events. | ||
|
||
### How The Graph Functions | ||
3. [Graph Node](/en/indexing/tooling/graph-node/) continuously scans the Ethereum blockchain for new blocks and filters for events relevant to a deployed Subgraph. | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Indexing blockchain data is very difficult, but The Graph makes it easy. The Graph learns how to index Ethereum data by using Subgraphs. Subgraphs are custom APIs built on blockchain data that extract data from a blockchain, processes it, and stores it so that it can be seamlessly queried via GraphQL. | ||
4. When a matching event is identified, Graph Node executes the Subgraph’s mapping logic, which is a WASM module that transforms event data into structured entities. These entities are subsequently stored and indexed. | ||
|
||
#### Specifics | ||
|
||
- The Graph uses Subgraph descriptions, which are known as the Subgraph manifest inside the Subgraph. | ||
|
||
- The Subgraph description outlines the smart contracts of interest for a Subgraph, the events within those contracts to focus on, and how to map event data to the data that The Graph will store in its database. | ||
|
||
- When creating a Subgraph, you need to write a Subgraph manifest. | ||
|
||
- After writing the `subgraph manifest`, you can use the Graph CLI to store the definition in IPFS and instruct an Indexer to start indexing data for that Subgraph. | ||
5. The dapp queries the Graph Node via a [GraphQL API](https://graphql.org/learn/), retrieving indexed data to render in the UI. Users can then take actions that generate new transactions, continuing the cycle. | ||
|
||
The diagram below provides more detailed information about the flow of data after a Subgraph manifest has been deployed with Ethereum transactions. | ||
|
||
 | ||
|
||
The flow follows these steps: | ||
|
||
1. A dapp adds data to Ethereum through a transaction on a smart contract. | ||
2. The smart contract emits one or more events while processing the transaction. | ||
3. Graph Node continually scans Ethereum for new blocks and the data for your Subgraph they may contain. | ||
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. | ||
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. | ||
|
||
## Next Steps | ||
|
||
The following sections provide a more in-depth look at Subgraphs, their deployment and data querying. | ||
|
||
Before you write your own Subgraph, it's recommended to explore [Graph Explorer](https://thegraph.com/explorer) and review some of the already deployed Subgraphs. Each Subgraph's page includes a GraphQL playground, allowing you to query its data. | ||
Explore [Graph Explorer](https://thegraph.com/explorer) to view and query existing Subgraphs. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.