- 1 The Graph protocol was established in 2018 as a decentralized network to provide a user-friendly wallet and platform for developers to access blockchain data.
- 2 The purpose of the developers of the Graph protocol was to create a decentralized system for easy record getting admission to, and querying for developers on blockchain networks.
The Graph protocol is a decentralized protocol for indexing and querying data stored on blockchain. The graph makes it possible to query data that is not possible to query directly.
The data for smart contracts like Uniswap and NFT initiatives like Ape Yacht Club is stored on the Ethereum blockchain. It only allows users to read basic data directly, not anything else.
In Bored Ape Yacht Club, the basic read operations can be performed on the contract, like getting details of the owner of a certain Ape, the content URI of an Ape based on their ID, or the total supply.
These read operations are programmed directly into the smart contract. The more advanced real-world queries and operations like aggregation, search, relationships, and essential filtering are not possible.
To get the above mentioned data points, every single transfer event needs to be processed that has ever been released, reading the metadata from IPFS using the token ID and IPFS hash, and then these are aggregated.
Decentralized applications (dApps) running in browsers take hours, or even days, to answer relatively simple questions.
Users can also build their own servers and 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.
Indexing blockchain data
Indexing of blockchain data is further complicated through blockchain properties like finality, chain reorganizations, or uncled blocks. It not only makes the process time consuming but also conceptually hard to retrieve the correct query results from blockchain data.
The Graph protocol solves this by being a decentralized protocol that indexes and enables the computing and efficient querying of blockchain data. These APIs, or indexed subgraphs, can then be queried with a standard GraphQL API.
Currently, there is a hosted service as well as a decentralized protocol with the same capabilities. Both the decentralized protocol and hosted service are backed by the open source implementation of Graph Node.
Working of The Graph Protocol
The Graph learns what and how to index Ethereum data based on the subgraph manifest. The subgraph description or manifest defines the smart contracts of interest for a subgraph, the events in those contracts to pay attention to, and how to map event data into data that the graph will store in its database.
Once the subgraph manifest is written, the Graph CLI is used to store the definition in IPFS and to tell the indexer to start indexing data for that subgraph.
The above picture shows details about the flow of data once a subgraph manifest has been deployed for dealing with Ethereum transactions.
Steps that the above flow follows:
Step 1: A decentralized app adds data to Ethereum through a transaction on a smart contract.
Step 2: The smart contract releases one or more events while processing the transaction.
Step 3: The Graph node continuously scans Ethereum for new blocks and the data for subgraphs they may contain.
Step 4: Graph Node finds Ethereum events for subgraphs in these blocks and runs the mapping hurdlers that were provided. The mapping is a WASM module that creates or updates the data entities that Graph Node stores in response to Ethereum events.
Step 5: The dApp queries the Graph Node for data indexed from the blockchain using the node’s GraphQL endpoint. Then the Graph node 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 steps continue in the form cycle.
The Graph Network
The Graph Network consists of Indexers, Curators and Delegators that provide services to the network and serve data to Web3 applications. Consumers use the applications and consume the data.
The Graph token, or GRT, is a work utility token that is an ERC-20, used to allocate resources in the network. Participants stake and use Graph tokens (GRT) to ensure the economic security of the Graph network and the integrity of the data that is being queried.
Indexers, Curators, and Developers can provide services and generate income from the network, proportional to the amount of work they perform and as per their GRT stake.
Curators are subgraph developers who assess which subgraphs are of high quality and need to be indexed by the Graph. Curators attach the GRT to the subgraph they believe in.
Node operators are tasked with providing indexing and quert services for the signaled subgraphs and must stake GRT in order to provide these services.
Delegators delegate GRT to indexers in order to contribute to running the network without installing a node.
Value of GRT
The GRT cryptocurrency derives its value from its ability to ensure the successful execution of smart contracts that depend on the Graph protocol.
GRT is the only cryptocurrency used for key network operations. Curators earn query fees and rewards from the protocol, and delegators earn part of the indexer fees for lending their GRT.
The one who owns and stakes GRT tokens can participate in decisions that will have a material impact on the software, voting on proposals for the rules that govern the platform’s use. Delegators can assign their voting rights to others to vote on their behalf.
Benefits of using the Graph Network
Flexible and Lower Cost structure
There are no contract fees or monthly fees. Users need to pay for the queries they use. Queries are priced in USD and are paid in GRT. The query costs can vary.
On average, there are less than 30,000 queries per month, as per the data released in December 2022.
On average, there are more than 3,000,000 queries per month, with a query cost of $750 per month on a total basis and $0.00025 on a per query basis. These costs are also based on the data released in December 2022.
On average, there are more than 30,000,000 queries per month, with a total cost of $4,500 per month and $0.00015 per query.
Other costs include backup costs ($50-$100) per month and engineering time based on a $200 per hour assumption.
No Setup Costs and Greater Operational Efficiency
There are no setup or overhead costs, no hardware requirements. Additionally, there are no outages due to centralized infrastructure, and it provides more time to concentrate on the core product. There is no need for backup servers, troubleshooting, or expensive engineering resources.
Reliability and Resiliency
The Graph’s decentralized network gives users access to geographic redundancy that does not exist while self-hosting a graph node. Queries are served reliably 99.9% of the time, and hundreds of independent indexers have achieved network security globally.
Steefan George is a crypto and blockchain enthusiast, with a remarkable grasp on market and technology. Having a graduate degree in computer science and an MBA in BFSI, he is an excellent technology writer at The Coin Republic. He is passionate about getting a billion of the human population onto Web3. His principle is to write like “explaining to a 6-year old”, so that a layman can learn the potential of, and get benefitted from this revolutionary technology.