This article is intended for people already familiar with The Graph protocol. It will be of most interest to Subgraph curators who want to learn the first steps required to evaluate a Subgraph. In the paragraphs below, I will present a simple Subgraph scoring algorithm. Please note that the purpose of this article is not to provide a ready-made solution, but rather a starting point for developing your own approach to analyzing Subgraphs. I also assume that the reader already has a basic understanding of how the Subgraph works. If you are a beginner, I would suggest reading The Graph documentation first and then returning to this tutorial.
The starting point:
First of all, you need to find the Subgraph page that you will be evaluating. The easiest way to do this is to type the following link into the address bar of your browser: https://thegraph.com/explorer/subgraph/ [subgraph_name]. Replace [subgraph_name] with the name of the Subgraph you are interested in. If you don't have a specific preference for what to analyze, you can find something that interests you in the Graph Explorer.
For an example of parsing in this article, I chose the following Subgraph: https://thegraph.com/explorer/subgraph/renproject/renvm
First of all, as soon as you find yourself on the Subgraph page, look at its description. Does it reflect well what data the subgraph provides? Then check if Subgraph has a Github account. If you have an account, open it and check for a README file. Inside this file you can also read the description of the Subgraph.
Getting a detailed understanding of what the Subgraph is doing:
Your next step will be to view the Subgraph manifesto. The manifest contains information about which contracts are analyzed by the Subgraph and which events he tracks in them.
go to https://ipfs.io/ipfs/ [ID] and replace [ID] with the "ID" of the Subgraph you are parsing (this information can be found on your Subgraph page in the Graph Explorer.
Find which contracts the Subgraph is analyzing. To do this, look at the following lines of code in the manifest: dataSources => mapping => source. Copy the contract address from the source, go to Etherscan and find that contract. See which project it belongs to and what transactions are taking place in it. Please note that the Subgraph you are analyzing may contain several contracts. In this case, check each of the contracts presented in the manifest.
Note: You can also find the manifest file on the Subgraph Github page under “subgraph.yaml” and compare it to the data obtained from https://ipfs.io. These data must be the same. Then you can also look at the “schema.graphql” file to see what data types are specified there. These specified types define the structure of the data that you can query and retrieve in The Explorer Playground of your Subgraph.
If you have some understanding of the Solidity programming language, you can also analyze the Etherscan contract to see what functions and what data are being called on it.
At this stage, you should already have an idea of what the Subgraph you are analyzing is doing and whether it is ready for use.
Exploring how the Subgraph works:
In this step, you will find out what events the Subgraph is watching and what handler functions it uses to get data.
Information about what contract events the analyzed Subgraph is watching can be found by looking at the manifest file (subgraph.yaml) in the following lines of code: dataSources => mapping => eventHandlers => event. This section will indicate the functions that the Ethereum contract calls. When this event is implemented, the Subgraph will make a note and call its own handler function, which is defined in its manifest in the following lines of code: dataSources => mapping => eventHandlers => handler.
Then open the ABI for the contracts defined in the manifest of the parsed Subgraph. (Note that ABI is a JSON list of contract functions and arguments.) The ABI can be found either in the GitHub of the analyzed Subgraph (in the "abis" folder), or at the address of the contract on etherscan in the "Contract" tab. Look through the "name" fields to see what functions are in the ABI - in fact, these are the events of interest to us and their names are usually so informative that you can understand by the name itself what this function performs. Pay special attention to the names of the functions that correspond to the event handler functions in the manifest of the parsed Subgraph. Also notice what arguments these functions take.
Finally, navigate to the “mappings” files in the github account of the parsed Subgraph (path: / src / mappings /), and find there the function names that match the names of the handler functions in the “eventHandlers” section of the parsed Subgraph manifest. Try to understand what type of data this subgraph handler function retrieves.
Evaluating the Subgraph:
At this stage, you should already have a good understanding of what events the Subgraph extracts from the contract and what data from these events it captures. Now is the time to think about what you have already figured out in the course of this analysis. Rate Subgraph and ask yourself the following questions:
What changes would you make to the “schema”, including adding or changing objects, fields, field types, data interactions, or any other improvements?
Are there already other Subgraphs who do similar things? Make a comparative description of the analyzed Subgraph and similar Subgraphs
Determine the degree of completeness, complexity and accuracy of the implementation of the analyzed Subgraph.
Is the data provided by the analyzed Subgraph useful?
Is there a way to improve the data provided by Subgraph?
Making Subgraph Better:
After analyzing the Subgraph above, think about what could be improved. Review the existing objects in the schema.graphql file and think about what other data would be useful to add to them
Then review the ABI again and, based on the function names, think about what other events can be monitored and what data we need for our Subgraph can be extracted from them.
Write down all your ideas for improving the analyzed Subgraph, because these are the future points for its further development.
Video guide: https://youtu.be/R3-WogeUPKo
RU guide: Развертывание и запуск SUBGRAPH на VPS Ubuntu 20.04 x64
EN guide: Deploying and running SUBGRAPH on a VPS Ubuntu 20.04 x64
Why do we believe in The Graph? What inspires us? Why is Graph so important to Web3?
Everything about the new direction of Web3 using the blockchain stack. Why is Graph so important to Web3?
Почему мы верим в The Graph? Что нас вдохновляет? Почему вам следует познакомиться с Graph Protocol!Почему мы верим в The Graph? Что нас вдохновляет? Почему вам следует познакомиться с Graph Protocol!
Official site: https://thegraph.com/
RU community THE GRAPH:
https://vk.com/thegraphru
https://ok.ru/thegraphru
My Discord: SHLIF9570