logo academy

The Graph: the blockchain archivist

February 23, 2022
7 min
The Graph: the blockchain archivist
You will learn

    The graph is a protocol and network for indexing blockchain data. In particular, it was created to solve the problems associated with the development of Dapps on Ethereum, which require precise data to be found very quickly.

    grt token

    What indexing actually is

    In short, indexing is the set of solutions that allow to find data quickly

    The index of books provides a brief overview of the information contained, allowing us to jump to the pages we want to consult. Similarly, in the field of computing, database indexes serve to speed up searches for data needed to run the software.

    The specific term for this type of search is “query” and will come in handy later. A query is the act of the user “interrogating” the database with code or keywords to obtain information.

    Google does something similar, indexing web pages and allowing users to immediately find what they are most likely to be interested in.

    Blockchains have grown by leaps and bounds not only in number of projects, but also in terms of data and history. Now, more than ever, they need protocols such as The Graph to speed up the search and use of the analytical data available on the various blockchains.

    How The Graph came about

    The project started with three Ethereum enthusiasts who had worked together on several startups: electrical engineer Yaniv Tal, computer scientist Jannis Pohlmann and roboticist Brandon Ramirez.

    Starting to develop on Ethereum in 2017, the three were overwhelmed by the amount of data available to developers, which was however not organised in any way. It was easy to develop smart contracts and execute them individually, but building complex dapps with user-friendly interfaces meant needing a lot of diverse data from the blockchain. Since this data had to be searched across the entire non-indexed blockchain, loading dapps ended up being very slow

    How do you search for data on the blockchain without indexing? By starting with the first block and analysing every single transaction contained in each block. If we count that Ethereum alone has millions of blocks, the search cannot be fast at all.

    On top of that, all popular block explorers, such as Etherscan for Ethereum, are companies and therefore centralised systems, whose software is closed source. This prevents unlicensed developers from building better versions without having to write new code from scratch. 

    The 3 developers started working on the whitepaper to solve all these problems and the following year, in 2018, The Graph project was announced. 

    In 2020, the pre-sale of the GRT token attracted a number of funds led by DCG and Coinbase Ventures, and a public ICO was launched in the same year.

    How The Graph works

    To sum up, The Graph has a solution to achieve 3 goals:

    1. Speeding up the performance of dapps that require specific data on blockchain
    2. Decentralise search engines on blockchain
    3. Decentralise app development tools and APIs, facilitating the development of other dapps

    The first part of the solution is language

    Usually, to manage and communicate with a database, the most common language is SQL, Structured Query Language. The Graph, on the other hand, uses a language originally developed by Facebook to query the data of systems such as Ethereum and IPFS: GraphQL. The advantage of this language is its flexibility, as it allows you to specify the topic you are interested in and the search criteria to be followed.

    The data available on The Graph are organised in “subgraphs” and each subgraph can include other subgraphs. Each app can publish its own APIs in its own subgraph, and also use those of other apps.

    The GRT token

    The Graph network could be defined as a Marketplace for queries, in fact the use of data is not free of charge as the curation of new data sets and indexing are proper jobs entrusted to specific figures.

    In this data marketplace, there is a clear need for a token and for strong tokenomics. This need is met by the ERC-20 and the GRT utility token, which will also be used for decentralised governance in the future.

    The roles participating in The Graph

    The two key figures for the network are Indexers and Curators.

    • Indexers – nodes that maintain and perform indexing by staking GRT tokens. For their services, they receive fees and rewards in GRT. Staked GRTs have a lockout period before they can be collected, and in case of malicious behaviour by indexers, they may be slashed.
    • Curators – can be users or developers who are in charge of reporting new subgraphs of quality and value to the ecosystem. Curators must deposit GRTs and generate proportional “shares” of the subgraphs they want to promote. They will then receive a percentage of the fees paid by consumers to use the subgraphs. Thus, Curators gain more benefit from promoting a subgraph that has a high probability of success and demand. This incentivises the proposal of quality content.

    Two minor figures contributing to the network are:

    • Fishermen, who check the accuracy of the protocol’s response to queries. We have also encountered a figure with the same name in Polkadot.
    • Arbitrators, who check the legitimacy of the indexers.

    Let’s move on to figures closer to the “client” perspective, who are not required to have technical skills:

    • Delegators are those who delegate their GRTs to indexers in order to receive a part of their staking rewards.
    • Consumers are of course those who query (via queries) the subgraphs and pay the indexers, delegators and curators. The price of this service is determined jointly by all participants in the exchange.
    how the graph works

    Ecosystem and use cases of The Graph

    Let’s turn to the practical side: what has The Graph achieved of all these promises?

    First of all, you can consult all the subgraphs yourself via the explorer available on this page.

    The solution is used by well-known dapps such as Uniswap, Decentraland, Synthetix and ENS.

    In addition, in beta version the protocol is also available for many Layer-2s of Ethereum and L1 blockchains such as BNB, Avalanche, Fantom, Near and xDai.

    The first dapp built on The Graph is Everest, a project registry for the Web3 that is maintained and updated by members of the community. Projects from any blockchain and of any type can be included in the registry: DAOs, Dapps, funds, no-profits, research projects etc.

    This is only the beginning: The Graph has a vast potential of applications. Think for example of an NFT marketplace aggregator – The Graph would allow providing market data of all kinds from all marketplaces in real-time.

    The Graph takes a leap forward in a vein started by projects such as Storj and IPFS, and other protocols concerned with providing decentralised storage as an alternative to Cloud providers such as Google and Amazon. In this sea of distributed data, the Graph is the compass.