The Graph: What It Is and How It Works
You may have heard about The Graph, the decentralized protocol aimed at indexing and retrieving data from blockchains. In other words, it is the solution to optimize access to databases that are usually not directly accessible.
The Graph helps query data for networks like Ethereum and IPFS. It also feeds many DeFi applications. With The Graph, any user can develop open APIs called subgraphs that DApps can query through GraphQL. All this is to recover data from the blockchain.
These open APIs make it easy for developers to build new products for the crypto ecosystem.
Most people consider The Graph the 'Google of blockchains' since it's a decentralized indexing service for blockchain protocols.
Understanding how The Graph works
The Graph is built on a proprietary network of nodes closely linked to the Ethereum network. The main idea behind it is simple: nodes work as information collectors from different blockchains. This information can be accessed through an API that allows Dapp developers to obtain the data they require more efficiently.
But to make it easier to understand, the essential operation of The Graph is to access, process, store and serve information from external services to third parties.
And what does it means? It's a bridge between Web2 and blockchain data. It reduces the friction of finding and working with encrypted and stored information in different blockchains.
Let's see it with a more practical example. Let's say you want to find an ice cream recipe online.
If you don't have a search engine (like Google), you need to know every single website online and type it directly in your browser. Finding ice cream recipes that way is probably challenging and time-consuming.
Google indexes all the information online, processes it, classifies it, and makes it easy to access. That way, you just need to type "chocolate ice cream recipe" and get your result instead of swimming through thousands of news, posts, articles, and pictures to find it.
The Graph works similarly but for blockchain, helping developers get the information and data they need.
As mentioned, it's a decentralized protocol aimed at indexing and retrieving data from blockchains. All this is possible thanks to a description of subgraphs known as a subgraph manifest.
This description defines the smart contracts of interest for a subgraph. Through these, the events of the contracts that need attention are selected, and the event data is mapped in the data of The Graph network that will store them in the database.
Once the subgraph manifest is written, the Graph CLI is used to store the definition in IPFS, and then the hosted service is requested to start indexing the data in the subgraph.
Getting to know the network contributors
Like any decentralized blockchain network, The Graph has a series of public nodes that are responsible for keeping the network.
Indexers
Indexers are an essential part of how The Graph works. The job of these nodes is to maintain a stake of Graph Tokens (GRT) and provide the most critical service: the indexing and processing of queries made on the network.
Each indexer has the task of participating in one or more subgraphs within The Graph. These "subgraphs" are the space to index and organize the information of a particular blockchain.
Indexers lend computational power to process all this information and maintain a rapidly accessible database to offer answers to network users. Staking allows holders of index nodes to earn rewards for their work.
However, the essential point is that GRT rewards are locked for some time within the network. This prevents indexing nodes from connecting and disconnecting to gain an advantage in the indexing process.
Curators
The curators are the ones who classify which subgraphs are of high quality, and, from there, they create a priority tree, which the indexers follow to carry out their work.
Its primary function is to point out which subgraphs deserve to be indexed within the network by the indexers. This classification is made by considering a series of criteria, such as the relevance of the blockchain, tokens, and query requests within the network for a specific subgraph.
The start-up of a curator node requires staking within the network to carry out the work.
Delegators
Delegators are not nodes within the network but people who have decided to delegate their stake to indexers to contribute to network security without having to manage a node themselves.
In other words, a delegator is a holder of GRT tokens that injects liquidity into an indexer to give it a more significant share of power within the network.
The GRT token
GRT is the native ERC-20 token of The Graph protocol. It was announced in October 2020 and was created to distribute rewards to those actively participating in the network.
The token has a total supply of 10 billion tokens. One peculiarity is that it burns when used for queries within the network. This means that inflation is controlled, favoring investors and participants.
The role of the GRT token is fundamental to the network's PoS protocol staking system. It benefits indexers, curators, and delegators, the essential pieces of the network.
Additionally, the GRT token helps decentralize the network by keeping the power of the network shared among multiple participants.
The Graph is a promising project that complements DeFi's goals. It effectively indexes blockchain data in an accessible and cost-effective way for developers and users. It also allows end users to benefit from maintaining an information ecosystem without third-party control.