The Graph 🛠Building decentralized, Serverless Applications
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
Join the The Graph for their workshop titled, "Building decentralized, Serverless Applications". Embark on a journey with ETHIndia, where innovation thrives, collaboration knows no bounds, and hierarchies fade into self-sovereign ownership. The most skilled web3 developers, designers and product builders from all around the globe came together for a weekend-long adventure to advance the Ethereum ecosystem at ETHIndia in December of 2023! ----------------- Follow us: https://x.com/ethglobal Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
[Music] welcome to my workshop um I'm going to teach you how to build decentralized server serverless applications with the gr my name is Aran Arisa I'm working as an ecosystem manager for the gra Foundation if you have any questions after this Workshop feel free to come to our boot or go to the gra.com Discord we have a a Discord channel that is that is uh dedicated to help helping hackers helping developers uh so if you have any questions and we are not at the boot if it's in the middle of the night you can come there and we'll help you out so first of all I I want to talk a little bit about why we need index data because the blockchain is open it's all public dat data but it is optimized for writing data and not for reading it you can uh look at it as a big Public Library where every day there's a new truckload of books coming in and they're just getting added to the end of the shelves every day and there's no ordering or sorting and it's fine if you go into the library and you want to look at one specific book you can find it you know where it is but if somebody asks you what are the top 10 books with the most pages in each book you would have to go into every single book look at the page count note it down and then sort your your table and that would take a long time similarly if you if you look at a more practical example uh say you want to build a analytics dashboard some of you might recognize this this is the analytics dashboard of unit B3 and and everything that you see on that page is coming from the graph looking at one of these for example if you want to see historic price action knowing that the price changes every single time there's a transaction if you wanted to to get that uh chart over there from just querying the blockchain directly you would have to make millions of eat calls find the price action of every single block and uh and then convert that into a into a table uh and into a chart and if you wanted to do that on the front end it would the front end would take literally uh hours or weeks or or days to to to load and that is not feasible so that's why we have indexing you need to pre-process that data and in web two you would do it by having your own server and you would just update that but there's a lot of uh a lot of inefficiencies to doing that first of all like running your own server would require a lot of um expertise a lot of uh a it's a lot of cost and it also is nowhere near as performant as we can get it with web three data so let's dive into that first of all I touched on this a little bit earlier like who needs index data and that was a question we asked when we started close to how many years seven eight years ago since see Inception of the graph and uh it turns out that everybody needs it uh we have over 84,000 subg graphs that have been created so far so every single D needs to have some form of data in the in the font and and with index data you can do aggregation you can do transformation of data before you you you show it on your front ENT so that's where you get from just having everything in just a list as in the web one of uh of data to actually creating like use useful user interfaces in the graph Network we have served over 1 trillion queries so far so that is what the graph does it uh gives you custom customized apis tailored to your data requirements and that includes Rich sorted filtered and aggregated data and allows for fully decentralized serverless applications uh after all if you're not fully decentralized a a a Dap that is relying on one centralized server is just an app if you're not fully decentralized you're still having that one source of failure so we currently support 45 different networks on uh a one of our products is the hosted service is a pre centralized service run by one of the core develop developer teams at the graph and we are in the process of migrating more and more chains over to our fully decentralized Network we are currently at seven chains but more is coming uh every month so uh we are currently expanding our multi-chain support and uh there's quite a few networks that are currently in the in the pipeline so and again why do we want the data layer to be fully decentralized well first of all there's no central point point of failure so there's no engineer that will call you at 5:00 a.m. in the morning and saying that your server went down or your uh your local government has put a ban on crypto so you are no longer allowed to use your servers it's innately load balanced and and geod distributed the economics indigraph network does encourage indexes to uh to to serve data in uh in like as much data as you need in in in that that region so innately in the in the economics of the grab network if there's more need in a in a certain area you will have more indexes serving that data in that area we have censorship resistance there's no as I mentioned there's no uh government that will take down your server because they are serving web three data and most of all and that is uh what most developers will focus on is that with 300 indexes competing to deliver fresh and cheap data with low latency and high Rel reliability we know that the best performance you'll get by using a decentralized service or using the grab so I'm going to give a quick pimer of what a subg graph is so a subg graph is the one of our data technologies that we are using at the graph and that we have prices for during this hackathon and the subgraph consists of three parts that you'll be working on if you you want to uh apply for any of our bounties uh for for subgraph development and that is the subgraph Manifest that's where you defined what data you need from onchain so so usually you would listen to events in in smart contracts so in the subg Manifest you would list the various contracts we support uh also any proxy proxy implementations or a factory sty implementations that will automatically be uh indexing any um any implementation uh compact implementation that foxy is pointing to or any uh of the the contacts generated by the the factory contact so here you define the network the contacts start block that you want to start indexing from and any events calls um can use uh also you can have con jobs uh running every X blocks so all of that will be defined in the sub manifest then you'll Define a subgraph schema where you'll Define what entities you want to have stored in your graphql database that's where you define uh say you have a defi uh defi application you might want to Define like users and trades and various entities and you can connect these entities that is all done in the schema that would be the data structure entities relation between the entities if you are going to build your own sub graph I highly recommend that you spend some time on creating a uh an intuitive schema that will save you a lot of time down the line and then the meat of the code is in the subgap mappings that's where you take the data that you get from the events and the the calls and you map it over to entities in your schema and it's in the mappings that you also uh do all the transformation of data or aggregation of data so say you want to create a Time series data or you want to create any uh like counts any uh any other like aggregation of data you would do that in the in the mappings and if this sounds a little bit complicated it's not that that much to to work that you need to work with it's only these three files and most of most of the things are happening in the schema and the in the mappings uh but you can also have the the CLI create a scaffold code for you and that allows you to create a subg and deploy it in less than five minutes and from there you can start working in working on more advanced entities and more advanced mapping code so that would map all the events in your smart contract one to one to entities in your schema and all of that is autogenerated usually i' I would create a I would have a demo here just showing how you can do it in five minutes uh I wasn't sure if we were going to have an ethernet cable and the internet so I I I I'm jumping over that uh this time but um if you need any help with creating your subg we fre to sub by our boot or reach out in Discord we also have a telegram channel for hackers so um yeah feel free to reach out we'll we'll help you through it and um yeah this the prices for our hackathon so we have prices for creating the best new subg grab we also have the the prices for best use of subgraph that could be your own or it could be an existing one and as I mentioned there's already 84,000 subgraphs that are open and free for anyone to use and uh you can find them at the gra.com we also also have a techn technology called substreams that we are excited for anyone that wants to use it a different approach to retrieving data from the blockchain it uses the fireos technology to extract all of the data in a in a client into flat files and then uses fire host uh use a substream uh technology to uh to extract data in a paralyzable way and that allows for extremely fast extraction of data which gives you gives us a lot more use cases or a lot of new use cases that subs don't have and if you want to take a look at that we have a a cheat sheet for substreams we have information about the substream also in our boot so so please stop by and um we'll give you a prim on that as well I also wanted to touch a little bit uh on how you can get more involved in the in the graph ecosystem and how the graph ecosystem looks um we currently have uh six core de teams at at the graph so we have the edod who was the original founders of the graph Network and uh who are currently like building the core protocol and new tools and applications we have streaming fast who we working on high performance data streaming uh semiotic who's F focusing on artificial intelligence and cryptography we have um The Guild who is the uh the leader of um or is one of the leading companies or working on on graphql in general and they are working with bit graph on composition analytics mutations and improving our rql apis we have rops who working on protocol economics and the index experience and we have misari uh who develop standards and innovate on on on subgraphs so they create if you go to uh subg graphs.
m.org you will find a lot of um standardized subgraphs across multip for like Landing protocols C5 protocols it's um with the standardization it allows you to to to analyze the data so if you if there's any data analysts or data scientist in the in the in the room you will find a a gold mine uh at the uh at their web P page they have standardized all uh standardized subbs for for all the the uh the common D5 platforms so that will allow you to create some analytics cost platforms um and then we also have uh DS and communities in the graph we'd be happy to also if you want to get more involved we have um DS that are working on uh on the advocate side on grants and communities we have a builder star that's is working on creating tooling documentation creating new subgraphs and sub streames and we Al also have infar that is working on um R&D focus on the the infrastructure providing side of of the protocol and we also have multiple other communities so if you want to get involved in graph ecosystem there's a lot of different Avenues uh no no matter what your skill set and background is you you're welcome to to to to reach out and we'll will help you find a place in the graph ecosystem
Automatic transcript — names and jargon may be misspelled.