Step-by-step instructions for evaluating the Subgraph
Denys # 6702
Find the Subgraph you are researching
a) use the search on the browser’s website https://thegraph.com/explorer
b) insert 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.
Conduct a cursory analysis of the Subgraph page
As an example, I will use one of the Subgraphs I am interested in, namely https://thegraph.com/explorer/subgraph/raid-guild/dai-subgrap
We can note that the Subgraph was updated after its creation, and not immediately, but after a certain time has passed — which leads us to believe that the Subgraph is used and important for its creator
The Entities value is quite large — it means that the subgraph is often referred to
Synchronization and connection to the Mainnet also indicates that the Subgraph is not abandoned, was not just a test version or “pen test”
This Subgraph does not have a link to the Github, but this does not mean that it is not possible to find the Github Subgraph.
Methods for detecting Github Subgraph links
1) through the name of the creator of the Subgraph
a) We can try to find it directly by pasting https://github.com/ [Subgraph creator name] into the address bar
b) Can try to drive the name of the creator of the Subgraph into the search engine with a GitHub postscript
2) through the name of the Subgraph himself
We drive in the name of the Subgraph with the Github postscript into the search bar of the browser
In this example, I used option 1a and went to the page https://github.com/raid-guild and found the section of interest to me with the analyzed Subgraph
The next step in understanding what the Subgraph is used for can be the discovery of the site or application for which this Subgraph was created. This step is optional, moreover, it is not always feasible, but it can help you better understand the purpose of the Subgraph, especially if you are not a programmer.
Methods of detecting what the subgraph is used for:
1) Write a message to the author of the subgraph asking where exactly the Subgraph is used
2) Find the site of the project in the search engine by the name of the Subgraph or by its author.
After detecting a site or application, you need to check whether they really apply for data to the analyzed Subgraph
How to check where requests go from the site:
a) Go to the site you found
b) Connect your wallet
c) Open the Inspector (Opt + Cmd + I for Macbook and CTRL + SHIFT + I for Windows).
d) Open the Network tab and XHR Filter
e) the page is updated, you navigate the site and see the requests that the site sends and whether there is a request among them to the API of the Subgraph we are analyzing
An example of checking site requests: https://i.imgur.com/A9F25Ab.png
The final stage before diving into the Subgraph code will be analyzing The GraphQL Schema and testing queries in the Playground
The Subgraph Outline is its creator’s idea of how the data collected by the Subgraph will be organized, displayed and presented to the user. The Scheme will briefly show why the Subgraph was created and based on the Scheme you should already have an idea of the complexity of the analyzed Subgraph
Here is an example of Raid-guild’s Expanded Dai-subgraph Subgraph Outline with a specific query example
A quick glance is enough to understand that the Subgraph is quite simple, since produces static data from the blockchain and does not perform any analytical or arithmetic procedures, it produces a very limited list of data and was clearly created for some highly specialized task
If the Subgraph were more complex, we would see much more data in the Scheme, perhaps the creators would add a description to the intuitively incomprehensible variables, the schema would use arithmetic and analytical procedures (we would understand this based on the presence of a Boolean data type, or from simple logic: if the Subgraph Scheme gives the user data that cannot be obtained by a regular viewing of the blockchain, then this means the Subgraph performs analytical or arithmetic procedures on the data before providing the user). What data types can be used in the Subgraph Scheme can be viewed here (eng): https://i.imgur.com/YkAdPN4.png
For a deeper understanding of the purpose of the Subgraph, we need to analyze his Manifesto. The manifesto, in simple terms, is needed to tell the Subgraph exactly what data needs to be retrieved from the blockchain, where to get it, how to structure it, and what procedures to perform on it.
There are 2 ways to access the manifest
1) go to https://ipfs.io/ipfs/ [ID] and replace [ID] with the “ID” of the Subgraph you are parsing
2) you can also find the manifest file on the Subgraph Github page under “subgraph.yaml”
Note: Manifests received by these two methods must match. If you have differences in the code of the manifests, then you probably found a different version of the GitHub Subgraph
We look at the manifest code
Highlighted areas are of particular interest.
Event, in simple terms, is what event occurred in the contract on the blockchain tracked by the Subgraph we are analyzing
Handler, in simple terms, this is how this event occurred will be reflected by the Subgraph we are analyzing
Address, this is the address of the contract, within which the Subgraph “searches” for the event that occurred
For a better understanding of the purpose of the analyzed Subgraph, we need to go to https://etherscan.io/ and find the contracts indicated in the Manifesto
The areas highlighted in red will help us better understand what the found contract is used for. Even if you do not know how to read the contract code, you can get a general idea by clicking on the link to the contract website or by looking at the latest transactions
In this case, we conclude that the Subgraph we are analyzing reflects data on the transfer of DAI stablecoins
By clicking on the link from the second contract of the manifesto of the Subgraph we are analyzing, we get to the Decentralized Finance Platform, where we can lend the Dai and earn by leasing the Dai.
Thus, without even reading or understanding the Contract Code (written in the Solidity language), we can assume that our Subgraph collects information about the operations of adding and removing DAI liquidity in this DeFi application
6. The final stage of evaluating the Subgraph will be the analysis of its Complexity, Completeness and Accuracy of information reflection.
The complexity has already been mentioned in this article: 1) pay attention to the logic of the provided data and whether you can get this data without the Subgraph simply from the blockchain 2) pay attention to the data types in the Subgraph Scheme. I would also like to add that the complexity of the Subgraph can be indirectly estimated by the size of the code of its manifest and schema: the more lines of code, the more complex the Subgraph will be by default. Of course, it is possible to write inefficient, but at the same time very cumbersome code, but for a person with a humanitarian mindset, there is no better option than using the above assumption.
The completeness of the information can be assessed from two sides. 1) Taking into account the idea you received about the purpose of the Subgraph, does it seem to you that the Subgraph collects All important data for analysis or is there something that you consider necessary to add to the raw data for collection 2) Are there any mistakes in writing the Subgraph that lead to the fact that not all raw data that should be reflected in the Subgraph is eventually reflected in it
The accuracy of the Subgraph is assessed based on the data obtained from it and their compliance with reality. The more complex the Subgraph’s code, the more likely it is any errors in its code, which can lead to displaying inaccurate information. If your subgraph simply reflects static data from the blockchain, it is very unlikely that there will be any problems with accuracy, but if the Subgraph is engaged in analytical procedures, then errors in the formulas can lead to displaying incorrect information to the user
The instruction was compiled in conjunction with MND#3412