The Graph is a decentralized indexing protocol that runs on blockchain technology. Its main responsibility is to index data from different blockchains and make them more accessible. This results in a decentralized database that’s faster and indexed for ad hoc queries through the standardized GraphQL language.
This protocol was founded in 2018 by Brandon Ramirez, Jannis Pohlmann and Yaniv Tal, with the aim of becoming the first application for data indexing on the blockchain. Years later, in 2020, they officially launched their own network, making this database natively decentralized.
Since then, this protocol has been increasingly used, and large projects such as Uniswap and Decentraland have adopted it as the main source of on-chain data.
What type of problems does The Graph solve?
Nowadays, DApps (Decentralized Applications) are growing exponentially – not only in regards to the amount of connected users/wallets, but also in their complexity and interoperability across multiple blockchains. This implies standardized and faster interconnections between the different smart contracts deployed within the ecosystem.
Collecting data from the blockchain and dealing with certain types of aggregations are well-known challenges. For custom queries, ideally we need to deploy our own validator, or at least a replica node for the desired blockchain. In more involved scenarios, we might do this for multiple blockchains that we want to collect data from.
Another alternative could be to subscribe to a node provider. There are several alternatives out there, notably Infura, Alchemy, QuickNode, Moralis, etc. However a subscription plan could result in the following weaknesses:
- Having your own centralized server, which ends up being more difficult to build and maintain.
- Possible data loss due to server downtime.
- Node as a service, possibly impacting payments by requiring specific functionalities such as access to Archive Nodes to obtain historical data from the blockchain.
- A lack of the desired index in our node provider.
The above reasons encouraged us to move forward with a more decentralized architecture. Here is where The Graph comes to the rescue, as it solves these problems and provides us with an accessible, decentralized and secure API.
How does The Graph work?
The way The Graph works is similar to Google's way of indexing, which is why it’s also known as "the Google of Blockchains."
The Graph ingests, processes, indexes and serves data based on the requirements of a manifest (subgraph manifest) that developers write, indicating four important things:
- Which blockchain to listen to
- Which contracts to work on
- Which entities to store
- What events to listen for and how to map them
These manifests created by programmers result in a file uploaded to IPFS, which a graph node uses to ultimately store the necessary data in a database.
This finally becomes a powerful public Graphql API called a subgraph, which anyone can consult and integrate into different DApps.
Participants within the network
This decentralized protocol is possible thanks to five different roles and participants within the network:
- Developers: In charge of developing the different subgraphs.
- Consumers: Those who consult the subgraphs.
- Indexers: Those who actually provide the service of running the servers, indexing the events and storing them in a database. As a reward, they will receive GRT.
- Curators: They identify the subgraphs that deserve to be indexed and use their own GRT for specific subgraphs. They get a share of the query fees based on a linkage curve.
- Delegators: They can bid on GRT with indexers to earn a portion of their query fees.
How has The Graph helped us at 3XM Group?
At 3XM, we use The Graph for collecting blockchain data on multiple queries. One of our most recent achievements involved a Monitoring dashboard for future trading protocols. This project entailed a decentralized web 3 that interacted with Avalanche and Arbitrum blockchains.
One of the ways we used The Graph was to calculate the Open Interest along the time of a decentralized exchange. This was evaluated using the sum of assets of long and short positions, which we obtained from a query of a previously deployed subgraph.
Without The Graph, we would have had to hire an Archive Node compatible with the necessary networks to create a process that calls the different smart contracts every X amount of blocks to get the historical data. This ends up being computationally expensive and it would be very easy to exceed the rate limit of our node provider.
This is where The Graph comes into play, as it creates a subgraph that points to the corresponding smart contracts. It’s easy to access the long and short positions’ specific data by listening to an event. Ta-da! By deploying this subgraph, we simplify service costs, computation and more.
What about The Graph’s weaknesses?
The Graph has certain limitations. Since its way of working and storing data is mainly through the different events that generate the calls to the smart contracts, it’s necessary to think in advance about how to code these in order to expose as much data as possible in the events.
If a smart contract doesn’t generate events on the inputs and outputs of a given method, they never existed within The Graph. This means that programmers must have a different mindset when developing.
Another "problem" that we encounter is when synchronizing our entities with the blockchain data. Depending on the network we’re working on, it could take days to be completely synchronized.
In addition, it’s easy to break the synchronization by having our mappings (events to entity data) incorrectly programmed in the subgraph, which causes the synchronization process to be stuck without showing any error in many cases.
GRT is an ERC20 token of the protocol, with a supply of 10,000,000,000,000. Its task is to decentralize the protocol through rewards to different network participants.
Its model is based on issuing tokens to indexers and curators but at the same time burning tokens through their use.
To get these tokens, we must either access the GRT Token Sale or be a participant in the network, which requires technical knowledge.
Currently The Graph Decentralized Network, where the subgraphs are maintained by the indexers, work only in Ethereum, but subgraphs on the Hosted Services support the following protocols:
- Bnb Chain
- Boba Network
- Cosmos Hub
The Graph is key to the future of blockchain
Due to the strong increase and adoption of blockchain technology in the world, protocols such as The Graph are becoming necessary when developing new applications. More and more large- and medium-sized companies are using and relying on this technology to index their data.
However, it’s also true that this protocol is relatively new and still has a long way to mature. Nevertheless, we believe The Graph is on the right track and will be key to rapidly adopting blockchain now and in the future.