The Graph: The “Google” of Blockchain

Connor D | December 12, 2021

Last updated on February 5th, 2022

The Graph is an indexing protocol for querying blockchain data, enabling the creation of fully decentralized applications. 

The lack of tooling in the Ethereum ecosystem frustrated many developers and made it difficult to develop decentralized applications. In late 2017 three engineers decided to start building The Graph to solve this problem. After a few years of work and many iterations, The Graph went live in December 2020. 

 

Share this:

What is Indexing?

Indexing reduces the time required to find a particular piece of information. For example, you are not going to read through an entire book to find one concept. Instead, you will go to the index pages where concepts are sorted alphabetically to find the specific page in the book where the concept is located. 

Similarly, in computer science, database indexes are used to find content. Instead of scanning the database multiple times to provide data to an SQL query, indexes speed up this process by providing quick access to relevant rows in a table. 

 

Why is Indexing is vital to Blockchains?

A blockchain consists of a chain of blocks. Contained inside each block is a list of transactions. Blocks are connected to their adjacent block and provide a linear, immutable history of what has happened on the blockchain. Because of this design, a naive approach to finding a piece of data such as a transaction would be to start at block one and search all the block transactions. If the transaction is not located inside block one, then you would continue on and search block two. If you cannot find the transition in block 2, then you keep going block by block until you find the transaction. This process would be highly inefficient. 

Blockchain explorers, such as Etherscan, build services for reading data on the blockchain by storing data in a database to allow for quick retrieval. 

This type of service is called an ingestion service as it consumes all the data and transfers it into a queryable format. Although this approach is usually acceptable, it requires trusting the company that provides the data. This is not ideal for building fully decentralized and permissionless applications. On top of this, all private crypto companies do not want other APIs to create their ingestion service, creating redundant work. This is why a decentralized protocol for querying blockchains was needed. 

 

What is The Graph

The graph aims to become one of the major core infrastructure projects necessary for building fully decentralized applications. The Graph focuses on decentralizing the query and API layers of the decentralized web by removing a critical trade-off that dapp developers are faced with because of the lack of tooling. Today developers need to choose between the dapp having good performance or being truly decentralized.

The protocol uses GraphQL to query different networks such as Ethereum or Aave. GraphQL allows for specifying which fields we are interested in and what search criteria we would like to apply. Queryable data is organized in the form of subgraphs. One decentralized application can make use of one or multiple sub-graphs. One subgraph can consist of one sub-graph or multiple subgraphs and provide a consolidated view of data the application may be interested in. 

The Graph provides an explorer making it easy to find subgraphs of the most popular protocols such as Uniswap or Livepeer. Uniswap subgraph allows access to lots of valuable data, for example, total volume across all trading pairs. Since the protocol was launched, volume data per trading pair and data about particular tokens or transactions.

 

What Data is Important to Index

When you look at index pages inside a textbook, you will notice not all the terms or concepts are indexed. This is because the writers will only put the concepts which will be searched the most often. The same idea applies to indexing Data.

To keep this as simple as possible, the more data there is, the more important it is to index, and the more often something is searched, the more essential it becomes to index.

 

Technical Architecture

To explain the architecture we will look at the different network participants starting with indexers. Indexers are node operators of The Graph. They can join the network by staking GRT tokens and running a Graph node. Their primary function is to index relevant subgraphs. Indexers earn rewards by indexing subgraphs and fees for serving queries on those subgraphs. They can also set prices for their services. To keep prices in check, each indexer competes with other indexers on top of showing the highest quality of their data. This creates a marketplace for the services provided by indexers. 

Consumers query indexers and pay them for providing data from different subgraphs. Consumers can be end-users, web services, or middleware. 

Curators are another network participant. Curators use their GRT tokens to signal what subgraphs are worth indexing. Curators can be either developer who wants to make sure their subgraphs are indexed or end-users that find a particular subgraph valuable and worth indexing. Curators are financially incentivized as they receive rewards proportional to how popular a specific subgraph becomes. 

Delegators stake their GRT on behalf of indexers to earn a portion of indexers’ rewards and fees. They do not have to run a Graph node.

The last participants are fishermen and arbitrators. fishermen and arbitrators become useful when a dispute happens. If an indexer provides incorrect data to the consumer the network participants cooperate to create a trustless and decentralized solution. For example, lets say a new centralized exchange has launched, and the team behind the project wants to allow other applications easy access to the exchange’s historical volume. To encourage indexers to index the new subgraph, a curator must step in and signal the new subgraph is worth indexing. 

Here we have two options. Assuming the new exchange was an anticipated project with potential, an existing curator will most likely step in and use the GRT tokens to signal the new subgraph’s usefulness. If the subgraph becomes popular, the curator will financially benefit. If a new exchange is not highly anticipated, the developers behind the project can become curators themselves and use their GRT to encourage indexers. Once this happens, indexers can step in and start indexing the subgraph. This process can take a few hours or even a few days, depending on how much data requires indexing. 

Once indexing is completed, consumers can query the subgraph. Each query issued by consumers requires payment in GRT, which the Query Engine handles. This Query Engine also acts as a trading engine, making decisions such as which indexers to do business with. To make this process smoother, The Graph uses payment channels between the consumer and indexer. If the indexer provides incorrect results, a dispute process can be initiated. 

 

GRT Tokenomics

GRT is a utility token that plays a vital role in The Graph’s network design. GRT is used by Curators to signal subgraph which are worth indexing. On top of this, it is staked by indexers to keep the incentives in check. Besides this, people who want to own GRT tokens but do not want to be indexers and run a GRT node can become delegators and earn a portion of the indexer’s reward. Consumers pay for queries in GRT.

The Graph had an initial supply of 10 billion GRT tokens and a new token issuance at 3% annually. This 3% is for paying the indexing rewards. There is a token burning mechanism expected to start at 1% of total protocol query fees. 

 

Conclusion

The graph protocol is one of the missing links that serve to increase the decentralisation of Dapps. It has the potential to become the Universal API Data Access Layer for the entire Web 3.0. With many similarities to google, many people call it “The google of blockchain.” If this comparison proves true, the potential for The Graph is massive. 

 

References

https://thegraph.com/blog/the-graph-network-in-depth-part-1 

https://thegraph.com/blog/the-graph-network-in-depth-part-2 

https://finematics.com/the-graph-explained/

Related Articles