Decentralizing querying in web3 through The Graph Protocol with Pranav Maheshwari

ETH Seoul 2022 · August 2022 · 20:12

Pranav Maheshwari, a core developer at Edge & Node, explains how The Graph protocol decentralizes the querying of blockchain data. The talk shows why reading data from a chain is hard, how subgraphs index smart contract events and expose them through GraphQL, and how indexers, curators, delegators and consumers make up the Graph Network. It argues that decentralized indexing matters more as Ethereum moves toward pruning history, notes the planned sunset of the hosted service, and invites developers to build subgraphs.

Speakers

Topics

From ETH Seoul 2022, hosted by Kryptoplanet.

Transcript

thank you thank you all right let's do it let's decentralize the world let's show them how it's done all right so basically i'll be doing some jokes in between so that you're interested but in general we are going to talk about web3 and how do we decentralize something which is very as important as querying blockchains all right i think the graph is one of such protocols which is not just decentralizing the the query markets but also is making a standard to making indexing happen on a blockchain i can say right now there are a few standards to write information inside a blockchain one of them is evm and i guess the graph is one such we have which has created

a standard to query the information from a blockchain via sub graphs so let's just get in um basically the graph wants to be as decentralized as possible and we have taken the first step in which the graph foundation is the governing body and there are a few code devs working on it i work for edge in node which is one of the core devs and there are other code devs also working on different different structures for example streaming fast which works on streaming the information in a parallelized manner and getting the queries in a very very decentralized manner similarly we have the guild which are the champions of graphql so on and so forth for others as well so that's about it but the first question which my friend cami yesterday also explained but

i like to explain it in a different manner is why the graph so basically i see like you know in uh coming to korea i see a lot of people stuck on their phone all the time in fact so much stuck that half of them have to like you know not even see the signals on the board they see it down the side right so much stuck and i'm sure most of them given how good looking they are must be on instagram right and uh basically on instagram how many times you post a picture if somebody's ad goes as good looking as me might be once in a 10 years or something but most of them are posting photos once but getting the information from that post like instagram maybe thousand times a day right so you write inside a particular

data structure once but read from it 10 000 times right as of now i would say the industry or the ecosystem is very much focused on writing inside the blockchain and that's where ben from starkware is working on and such other l2 protocols are working on but i think if we want to make a web 3s standard blockchain a reality in like getting you know the push forward to decentralization in internet we will need to at some point in time get reads from the blockchain also in a very awesome and nice manner and the biggest problem is that when you try to query a blockchain you get a block like this you just need the blue information but you'll have to get through all the blocks study a particular part of it and then get that kind of an information

which is not just like tough rigorous but also makes blockchains really really tough to get information from so blockchain i'm sure is a security first technology and they have been built only to have security decentralization censorship resistance and stuff like that we all stand for but to make blockchain really implementable we'll have to not just get the rights in the right manner with scaling but also do the reads from the blockchain in a decentralized fashion and also in the right manner so that our code does not look like this this is so i would not use the words if i'm not allowed to right this is this is this is for any developer this is a very big

nightmare just scanning every block finding every information getting all the information and then curing it oh my god no wonder why blockchain engineers are so highly paid right okay cool that's that's a joke on me but anyways so that's that's how you actually like you know get the information if you don't use the graph because people query it directly from the blockchain it's like a user interface that exists that writes inside the blockchain and we have awesome l2 solutions to do that with scaling but how do you read that information either you query every block find every place and then get the information or the second way which is even more like shittier and not web 3 centric is using servers you store the

information in server and get that information that's not at all web3 right remember decentralization does not matter until it does right there are only black swan events when you come to know that decentralization is something we stand for and we have seen that in the past few months with c5 going abrupt and stuff like that and that's why we need to build for future with the graph all right so the graph is the query layer between your blockchain and the user interface you write every information like you know using the blockchain stock where maybe ben you told me to say that so yeah start net tokens just kidding so you get that information and you want to

get that information to your user interface for that you need to use something like a middleware which is the graph protocol and that's where where the infrastructure comes in i'm sure it's highly sophisticated but because we are in a builders conference i would like to go through it in a very very quick manner all right so basically what happens is your dap first does a transaction right and writes inside a smart contract which has events triggering on it every smart contract in solidity as of now has events right and those events are what are caught by graph node they actually listen to those kind of events those events then are stored via the graph protocol in a storage

and made such that you can query them via the graphql api so we go through it once again little sophisticated but let's get let's understand it basically you have a smart contract these are events some event is triggered that is inside a graph node that graph node actually gets the information stores it and it's in such a manner that you can query it via the graphql api that's how simple and awesome this is and i would say graph node is open sourced and i would say one of those awesome public goods that people can use to query information right now i would say uh most of the web 3 world including uni swap sushi swap all the awesome d5 nft protocols either use the graph

or use the graph locally running their graph nodes locally so you know our biggest competitors is us only again uh so that's that's that's how like you know uh it's industry standards we are making with the graph this is one such uni swap subgraph and basically why don't you see it in the forefront is because it is powering this the api if you go if you're an if you're a developer you go on the network end and you find out how do you get this kind of information in unisop you'll be able to find out it uses the dot com api.thegraph.com uh unisop v2 and that's how web the graph actually empowers the infrastructure of web3

so this is how it works right when you are creating a smart contract make sure you have certain events which can be fired via sub graphs so that you can get the information to your ui that's how a web 3 stack is built you cannot run servers on ethereum and call it dap no that's just an application running on ethereum and maybe you want to launch a token to have a money grab for that's not how web 3 will be built if you really want to stand for web3 really want to send a stand for decentralization you will have to use the web3 stack you cannot use aws servers and call it decent lives because i'm sure amazon as of what i know today is not decent lies the stock price is still up right that's

why no again again so i'll keep cracking these one of these will work believe me so basically that's why you need to use the web3 stack and if you don't understand how web3 stack works again i would suggest you to check cami's workshop yesterday in which she explained that when you're building a dap you need certain middlewares so that that blockchain that you're squaring from is usable and one such middleware to use is the graph right we are right now live on 39 chains as of now sorry ben not on stark net but soon right similarly we are live on 39 chains most of the evm chains as well as near which is a non-ebm chain and we just announced being live on cosmos

so if you're building such an important critical piece of infrastructure and i'm lecturing you guys on why decentralization matters and giving you certain codes like steve job levels like almost how how do i call like you know if i'm working on a middleware that it's decentralized just imagine you are doing something as important as querying information from the blockchain to the dashboard and from that queried information people will be taking let's say some arbitrage trades if that information is rugged or is like you know censored by a particular database then i would say we are not there yet we are still building a middleware which is centralized and again it has points of failure and stuff like that

and that's why boom we launched the graph network not today one year ago okay so basically we launched the graph network the graph network is the way you decentralize querying in blockchains if you are querying a decentralized blockchain it has to be in a decentralized manner right so basically back in 2019 we launched the hosted service which was the mvp just to make sure that what we are building and the architecture that we have is good enough to actually like you know query the web 3 world and make sure it works we got the mvp we got most amount of adoption uh most of the d5s of the world most of the nfts of the world do use the

graph hosted service at that point in time and then we were like no this is not it like you know then we launch a token then we rest that's not how it works you have to make the decentralization keep on happening right and that's when we launched the graph network it's like the decentralized version of the hosted service in the hosted service there is one pers one particular entity indexing your information putting the data and putting it out to the graphql information but in the graph there are different different participants which actually make this whole sophisticated querying model come to truth just imagine you have to query something as sophisticated and

decentralized as ethereum right and you have to do it in a decentralized manner i'm sure it is tough and that's why there are certain things i would like to explain you about this basically the graph participants again i touched a brief about them in my middle talk but again i would like to talk a little bit about them the first one are the indexers the indexers actually index the information that is required by you there are thousands of subgraphs right and indexers pick a few of these sub graphs so that they can index that information from you the second one are the curators how do indexers come to know which particular subgraph to index which particular place to go for to getting which particular information and that's where curator signal curators signal the

graph token on uh the graph network saying that this sub graph is very important something like crypto fees dot info such an important page from that page i think most of us come to know which particular protocol is doing great how much query fees one is generating and if that is querying api.thegraph.com by the way it does how do you make sure that it is not censored right curators make sure that they curate enough on such subgraph that most amount of indexing is done from them right so curators curate on a particular sub graph and more the curation more the indexers more the indexers more the decentralization right then we have delegators which are like you can say uh passive income earners on the graph

network and then there are consumers uniswap subgraph was created by the uniswap team but it is actually queried by many like many many uh dashboards of the world many many applications of the world there is rotki app and whatnot which actually uses the uni swap sub graph to get information in the front end right so basically sub graphs are created by dapps but are used by the world because we believe that apis or information is again a public good simple example twitter launched their api back in 2015 i guess or 16 and many people built businesses out of the

twitter api just to get information and things like that and when they became when the information or all this api model became successful they were like yeah just f off we will we are closing the api business all the businesses that were created from the twitter api were shut down right so that's why i believe that apis that are built in the world have to be a public good anybody can query them anybody can get them and that too in a decent live fashion and that's where the graph comes in you can say the graph is one of those public goods in which information on the blockchain is queryable in a decentralized fashion only if you use the graph network right

so this is how it works again just uh i i i'm a i was a very dumb kid growing up i used to revise 100 times and then also get 2 out of 50. so i'm going to follow that again basically there's a query market right query market actually has all the sub graphs listed for example this is a query market right that the graph network has there are different different sub graphs that are deployed by different different people right but the curators are the one which tell you which sub graph is the most important one as of now you can see lido the merge is happening lido is coming it is one of the most important sub graph might need most number of uh decentralization by that we mean most number of indexers and that's why it has 175 k grt curation in it right so more the curation more

indexers index the lido sub graph more the indexers index more is the decentralization that happens how do you consume the information from the uh lido ap lido sub graph you go on the sub graph catch the api and start querying it you pay per query cost of service is pay per query right and i uh right now we have 165 indexers 10 000 delegators 2 500 curators and many subgraph if you're a subgraph developer go develop a sub graph on the network i'll be around if you are a dap who wants to migrate and wants to taste the flavor of decentralization please catch me up i'm one of those who really like the decentralization ice cream uh and

that's why gelato is my favorite ice cream okay cool anyways uh curators uh which are 2500 then there are delegators and basically if you are somebody who understands the industry and knows which subgraph can be important go curate on this on the graph network if you are somebody who is uh who maximizes why decentralized querying is important go ahead and delegate on the graph if you are somebody very technical right somebody who can really write cairo code then please go and index on the graph all right so basically i believe right now there is a lot of hype and lot of real projects and you really understand

which protocol or project is doing good when the revenue or real people using the graph or that particular protocol are existing right i think there are many people who store information in the rv thing and that's why like you know rv is one such which has real value accruing on it people pay in rv tokens to store information in rv but second one is the graph right if you want to get decentralized query you pay in grt token and since we launched the network we have like a 2 200 year-on-year increment in the number of subgraphs that have deployed and the kind of queries we are getting so i would suggest you guys to check it out

so there are about you're not the first one who would ever deploy to the graph network if you are there there are so many who already exist it's just that you will be the one which will be tasting the flowers of decentralization right now all right so that's that's that's about it now talking a little bit about the ethereum mission and how the graph is aligned on that some of you might have seen vitalik's talk in which he told that there is a merge happening right now all of us are excited about it yay i hope it does right i know the timelines but cool cool yeah ethereum has paid for this so yeah cool so anyways uh basically uh there is merge happening right now then there is spurge happening which is

sharding and stuff and then there is purge happening purge is basically uh in which ethereum will get over all the historic data that exists in ethereum right now you want to get information you have a full node running if you want don't want to use the graph you start querying information from ethereum but as per ethereum and many like people who are working in ethereum including vitalik they think that it's not ethereum's goal to read information from the blockchain it is just there to write information from the blockchain and you know other l2s to write the information but it does not want to get people to read that information and that's why eip 444 is coming purge is coming and that's where the graph fits in

ethereum in the web 3 world will be the one which will be storing the information or storing the final state where starkware will be the one which is you know doing all the query all the computation i hope but uh but but uh if you want to get that blockchain information outside right how do you get that i think you have to use the graph then right now it's an option to be decentralized in the future it will be a compulsion to have decent life squaring that's why i would suggest you all guys to start on the mission build a sub graph and i'm sure you're not gonna regret it and because like you know we are so much into decentralization and we believe we are solving this problem of ethereum of

eip for eip444 and the blockchain data we have announced the sunset of the hosted service which is the centralized product of the graph as well there could be an op there could have been an option to like you know okay the hosted service is working great maybe the graph network requires certain kind of participation and its little pinpoint let's just like you know ask people to pay for this kind of service but the graph protocol does not stand for that the graph protocol stands for decentralization and that was the reason it was created and that is the reason we have told that we are gonna sunset the hosted service soon right we are gonna send side the centralized infrastructure so that in the future whoever queries

information from the blockchain does not get censored whoever creates businesses like twitter people did on twitter api creates businesses on blockchain information they never get censored they have no problems in running their own businesses and basically all the information and data of the world is decentralized so this is the roadmap i would suggest you guys all to check because there are so many things that we have to do i would say like vitalik once said that you know uh ethereum is 40 complete bitcoin is 80 complete i would say the graph is 20 complete don't quote me on that but something like that okay around 20 complete and there is so much that we have to do so join the mission make sub graphs index on the blockchain

curate on the network query the graph network and i'll see you around in the web3 world