The Graph is a decentralized protocol that helps with indexing and querying data from blockchains like Ethereum. It functions as a layer that sits between decentralized applications and their data sources, making the data easily accessible. Developers define how data should be indexed and structured from smart contracts using a subgraph manifest file. Graph nodes then continuously scan blockchains for new data and update the stored indices based on events from smart contracts. Decentralized applications can perform complex queries on the indexed data through the GraphQL interface.
2. Introduction
2
If you have been keeping up with the advances in the blockchain space, you may have
heard of the Graph protocol. The Graph (GRT) is a decentralized, censorship resistant,
and open-source indexing platform for blockchain data. By specific norms or schemes,
data is arranged in an organized manner by the Graph. The Graph Protocol is often
referred to as the Google of Blockchain.
In case you are still not clear on “what is the Graph”, in this post we try to answer
your query in further detail, and also see the answer to another popular query, “how
does the Graph Work?”
3. What is The Graph?
3
In simple terms, the Graph is a decentralized protocol that helps for indexing and
querying data from blockchains. With the help of the Graph, it’s possible to query data
that is usually difficult for users to access directly. The Graph protocol can be used to
search for any Ethereum data through simple queries.
Why was the Graph protocol needed in the first place? DeFi and NFT projects like
Uniswap and Bored Ape Yacht Club store data on Ethereum Blockchain that’s hard to read
or query. For Bored Ape Yacht Club, the information like supply and other basic
information is available. This is because it is totally programmed into smart contracts. But
for advanced queries like aggregation and search, as well as for filtering across specific
address holdings, smart contracts are not enough. To obtain this data, we need to
process every transaction that was ever emitted and read the metadata from IPFS (Inter
Planetary File System) using Token ID and IPFS hash. Moreover the whole process will
take hours or even days to finally access the data we need.
4. History of the Graph Protocol
Nowadays, web applications like Facebook, Google, Youtube, and LinkedIn are well-
known. But these applications store data with centralized corporations that play a major
role in monopolism. This centralization will be in the hands of a few, and this affects the
reduction of economic opportunities and self-determination for many.
Even after the introduction of the blockchain-based decentralized applications (DApps),
the data was either owned or managed by the community. In these cases, the data is in
the hands of users as they control their data. As DApps are becoming more popular, the
data is also increasing rapidly. Operations like filtering, pagination and sorting require
creating and maintaining indexes, which takes lots of time to process.
To change this, the Graph was introduced. The Graph protocol provides the
infrastructure layer for the emerging web3 and solves the issues with querying and
organizing data.
5. How Does the Graph Work?
5
Now that we know ‘what is graph blockchain?’ let’s have a look at ‘how does the graph
work?’ Through a subgraph description, the Graph learns how and what data to index on
Ethereum: this is known as a subgraph manifest. After writing the subgraph manifest, we
use the Graph CLI to store the definition in IPFS and command the indexers to index data
for that subgraph.
The Graph works by first allowing decentralized applications to add data to Ethereum
through transactions on smart contracts. Through the transaction, one or more events
are emitted by the smart contract. The Graph Node then continuously scans for the new
blocks and the data for your subgraphs that they may contain. When the Node finds one,
it updates the data entities that the Graph Node stores in response to Ethereum events.
The application then queries the Graph Node through a complex process using GraphQL
to get the index data. Finally, the data sourced is displayed to the end user.
6. The Graph is among the newer web3 projects, launched only in the
December of 2020. The Graph protocol assures users with
trustworthy on-chain data in the field of blockchain, and many well-
known blockchain platforms already endorse the project. The future
of GRT looks very bright indeed.
6