The Graph 🛠️ Querying Web3 Data
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
Join us for a Graph workshop! From November 17-19 2023, ETHGlobal welcomed developers from around the globe to take part in shaping the future of Ethereum at ETHGlobal Istanbul. Over $600,000 USD in prizes were given away at the prestige Istanbul Congress Center... thanks for an amazing weekend hackers! ----------------- Follow us: https://x.com/ETHGlobal?s=20 Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com
Transcript
[Music] I'll be talking about quering web3 data with the graph right before we start the reason we attend hackathons is to learn but all upon that we also attend hackathons to actually win prices for sure right uh the money aspect so the graph is giving out bounties if you build a new subgraph if you build a new subgraph we get give you $2,500 uh we have three prizes 2,500 ,700 and $800 uh for use of a new existing subgraph you can get this kind of a price and if you're building a substream which is not subgraphs totally different then uh this is the price that you can expect so I will be giving a workshop on querying an existing subgraph if you want to know details as to how do you build a new subgraph then this is the particular Workshop you should be looking into this is the QR code for that if you're building a new subgraph then uh just uh scan this particular uh QR code this is for building new subgraphs uh I will be talking about querying existing subgraphs all right yeah go ahead as fast as you can uh let's move forward as I told you I'll be talking about uh how do you query existing new subgraphs so first of all we need to understand what is a subgraph subgraph is basically a tool to index blockchain data and what do you mean by that is basically our favorite blockchains give us data like this like you see on the upper side and these these wooden things are tools to get that un uh verified data un like cluttered data into like you know good forms that we can be used right a particular block on the blockchain looks like this it has data from all the protocols of the world it has data from Makow it has data from Uma it has data from Unis swap how do you get the data that you want right for that you have to use a tool called subgraph which converts this particular cluttered block of a blockchain into something like this which is queriable via databases all right so if you might know you might have used Unis Swap and Unis swap has their own subgraph using the subgraph they have extracted the information from the blockchain and given these kind of dashboards for you what do you need to have a subgraph you need uh a smart contract address of your subgraph uh you need a smart contract address of your uh smart contract uh you need a schema that you're looking to query and some structure some code so that you can convert the blockchain data in the schema that you want and the output is a graphql API from again you need a smart contract address a schema design that you're looking for and a structure so that it can convert the cluttered uh data of the blockchain of your particular protocol into graphql apis right uh this is uh where the Hub of blockchain uh subgraphs exist almost all the protocols in web 3 including Unis swap balancer live peer have a subgraph of their own so basically if you're trying to get information about Unis swap if you're trying to get information about balancer if you're trying to get information about whoever you want you get it from uh these uh explorers the gra.com Explorer and uh you can query the protocol that you would like all right what is the graph network uh initially in 2019 we launched the graphs hosted service which is a centralized SAS hosted service in which you used to connect to GitHub and get your subgraphs deployed but eventually in 2021 we launched the decentralized graph Network which is uh 250 plus indexers 7 plus chains and thousands of subgraphs to give you decentralized quering so that we can finish the graph Network and for this particular hackathon if you're trying to win a prize we would be judging you guys based on uh indexing the graphs decentralized network if the subgraph does not exist on the network approach our booth let us know if uh we'll let you know if it does not you can go for the hosted service otherwise you have to query the graph Network to build a good dashboard or you know your idea and work upon that uh steps to query the graph Network create a API key uh you will uh first of all access the Explorer sign up uh create a API key design a sub particular subgraph query and then integrate it with your dap or your react front end wherever you're looking at let's do a practical of the same all right I go to the gra.com here this is where you get all the information about all the subgraphs that have been deployed by different different protocols see uh we have pull pull together live perer open AUD dodo enzyme all these all right if I want to create uh or if I want to query a particular subgraph all I do is first of all I okay I'm signed in already I sign it sign in with my metamask right after that I go to the subgraph studio and I create an API key over here create an API key let's name it uh e Global let's name it e Global and my API key is created this particular API key I can use to query the graph uh different different subgraphs that exist for example if I want to query uh let's say live Pier subgraph I have to go on the Explorer click on life Pier subgraph over here and then click on query here I have to just uh design my query over here the API key and I'll be able to you know get the data from Life Pier blockchain this is how the data looks like we'll be going going into depths of that how do you you know query and stuff like that how you create a particular graphql query but this is how you first of all go to a particular subgraph find out whichever protocol you're trying to index secondly go to that particular you know uh subgraph create a particular schema design that you're looking for query that particular subgraph and use the API key that I've just uh guided you to use all right so this is about it uh how do you find the subg graph that you're trying to index for example if I go on the graph Explorer let's say try go for the arbitrum one the graph network is deployed on Main net and arbitrum and we are moving every subgraph from Main net to arbitrum uh so like you should check on both the networks there are 485 subgraphs on the arbitrum network uh so basically if I want to actually query crypto punks I will find at least five different variations of Crypt Punk subgraphs created how do I know which which is the most high quality uh you know subgraph that exists uh for that there are a few parameters you can check first of all if it is a misari subgraph you can find out all the misari subgraphs on subgraphs doxyz uh let me just give you a link to that all the subgraphs these are pretty high quality subgraphs that misari the uh the analytics company have created themselves they are one of the codev of the graph as well so you can just go and check these subgraphs out if they're not if you're trying to query something which is not in misari subgraphs then how do you check is basically you first of all go and check the documentation the curation level of that particular subgraph and also the comments of that particular subgraph for example if I go to these I would want to pick uh this particular subgraph for example the reason behind that is uh first of all I know Jerry and the other reason uh the more crypto permissionless reason is because this particular subgraph if you see over here as good documentation right if I go on the sub uh on the schema. graphql that person has given good comments on these things that me that makes me feel that the schema is very rich and I can get the data I want for Crypt punks that you know I would need for my dashboarding uh hack that I'm creating right let's actually uh you know it in when you're quering a particular subgraph not creating one it's about the questions you ask not the answers you get right so let's actually query this Crypt Punk subgraph to get two things first of all let's try to get the uh sales of first 10 crypto punks ever done all right I go here I go on the playground for now and here if you can see over here the these are the schemas that Jerry created I will just you know drop these down I don't want any of this I'm looking for transfers actually where is transfers transfers yeah this is the transfers and I'm looking for first 10 right uh and in that I'm looking for the sub for the Crypt Punk ID and the time stamp that they were done on plus order by descending order so the one which was done the first should be given to me first see here I'm able to get all the Crypt Punk IDs with when they were like first transferred by descending order right so I'm so easily able to get the schema over here right see what schema I'm looking for and able to uh get the information that's required to create a very good dashboard that I was looking for first uh qu solved the second one the total value of all sales the total Supply and the total number of sales on the Crypt Punk smart contract how do I get this crazy information the total sales and stuff like that how do I get this the first thing I do is uh I go on Crypt punks again I search contracts over here and yeah here it is total Supply total demand uh total uh sales and total you know this thing I don't need transfers I'll just not use it and uh here you can see the total Supply the total demand the total amount traded which is a good amount honestly uh so this is how you can query a particular sub graph to create awesome dashboards again just to uh reiterate and revise here is the query button I just use this particular query for my graphql queries that I'm looking at all right uh this is mostly about it this is the particular uh you know uh Workshop repo that you can look into and this is all that I taught you uh you can look into it there are two interesting examples that I would be looking uh like you know that I want to give you for this particular uh Workshop session somebody known as David mial uh just looked into these particular subgraphs and created something very important for whole of the crypto industry that we all look into the crypto fee info dashboard this crypto fee info dashboard uses subgraphs of various protocols like Unis swap a GMX arbitrum and gives you this information right and all of us have been using it this is just a very small hack that all of us have used so subgraphs can be very powerful subgraph dashboarding for one uh oneplay solution can be very powerful L2 beats uh crypto crypto fee info the money printer. info all these dashboards have been created by querying subgraphs so if you are creating a hackathon I would highly encourage you to look into something like that of a use case and create a dashboard of your own uh just to rectify and you know tell you that I'm not lying you can go over here on Unis Swap and see that they the the source of this particular information is the gra.
com itself right so this is one uh such idea that you can look into another uh uh like you know idea is somebody created something called dap Locker right dap Locker is like d analytics but using subgraphs and this looks pretty cool uh so if you're creating rather a project a Dap itself you and you want you know know uh these analytics dashboards you can actually just pick and choose one of these analytics dashboards yourself or create one using what they have created all right just to summarize use the graph Network query the subgraphs based on the protocol you're looking for and thirdly do some querying on the uh on the playground and then implement it on your dashboards all right that's uh most about it one last example that I'm looking to give you is of course the graph loves AI like Microsoft and Google I think and the graph also created a a model to actually instead of querying things by graphql and these nerdy Tech behaviors you can just write a query based on natural language process it and get the information that you're looking for for different protocols and for that another uh codf Team of the graph which is semiotic worked out on a detail and created something called Agent C right in this agency what we'll be doing uh what they have done is they have uh like uh taken all the data from Unis swap subgraph trained it on a model and now I can just use natural uh query language processing to get the information that I want right let's uh do something very interesting for example let me just type uh what is the most uh okay what is the least traded pair on Unis swap it takes time but uh it gives you the results ah people say blockchains are slow AI is slower so the least traded pair is Al USD and Al e uh anybody else wants to query something else interesting on Unis swap subgraphs I can just do it right now by the way this is not whitelisted if you want to use this particular product for your hackathon come to our booth and we'll get you wh listed to play around with Unis Swap subgraphs this is only for UNIS swap protocol right now we are expanding and going to more but yeah this is trained on substreams of Unis swap any any any interesting query or uh are we good oh go ahead um does it understand profitability would you ask what is the most profitable LP well we can see what is if it doesn't don't kill me but the most profitable LP on Unis swap let's see can we deploy toia can you deploy to sepolia testnet for sure you can yeah sepolia is the main test of ethereum nowadays the most profitable LP of Unis swap W usdc is the total Prof it gave you the total profit so it is w and usdc in case I'm not giving any Financial advice but AI can I guess it's not under you know regulation awesome thank you if you have uh any further questions do drop by the booth this is my contact information you can scan it and get all the information that's [Applause] required
Automatic transcript — names and jargon may be misspelled.