Full-Stack dApp Development with Scaffold-ETH and The Graph, Day 4

Urbe Campus powered by Arbitrum · October 2024 · 2:34:18

Edge & Node engineer and BuidlGuild member Kevin Jones teaches full-stack dapp development with Scaffold-ETH, a Yarn monorepo with Next.js, TypeScript and RainbowKit, and adds a branch that builds a subgraph with The Graph. Students deploy and verify a contract on Arbitrum Sepolia, wire up the front end and troubleshoot setup problems live on the fourth day of the Urbe Campus bootcamp powered by Arbitrum.

Speakers

Topics

From Urbe Campus powered by Arbitrum, hosted by Urbe.eth.

Transcript

[Music] cool thank you guys that was [Applause] amazing cool all right so uh we're going to get started uh I had this up earlier uh I think most of you guys probably have this stuff going um but you might not have Docker installed so that would be the only thing that um and you don't

need to do it right now we can do it at the Break um but at some point you're going to need Docker for the solution um hello everyone my name is Kevin Jones uh so I am a deil engineer working for edgen node um I also am a core member of the build Guild uh so I I work on the scaffold eth project supporting that uh and really today I'm going to be talking to you guys about uh full stack adap development so uh hopefully this is going to kind of arm you to really have everything you need to like build a really cool project for this uh pretty quickly that's what scaffold e is actually originally created for is like to rapidly prototype and build stuff um and then I'm going to also show off our integration with the graph so we have a

special build of scaffold e a special Branch I guess you you would call it uh where we're going to you know teach you how you can build a subgraph as well um you don't the requirement for the hackathon this weekend is not to use the uh to build a subgraph but it is valuable information for you guys as developers um to understand the ecosystem and how to build one so I'm going to at least show you guys how to do that um so scaffold e what is it so scaffold e is a project uh that is built around a yarn repo so a yarn mono repo and the concept with scaffold eth is it comes with kind of everything you need to build a de Right comes with nextjs with typescript mostly it will support

JavaScript so you can write JavaScript it comes with rainbow kit which is like uh basically has like the provider hookups for you to be able to connect your wallet if you want to use some kind of like wallet connect or something like that it also comes with a virtualized chain that you can run locally so there's two options I'm going to be talking strictly about hard hat I would recommend you guys just kind of stick with hard hat because you guys have already learned it from Matas but there is a Foundry version as well so you can spin up scaffold these a Foundry the build that I'm going to be using today is the subgraph package which is only on hard hat but Foundry is there so for some reason somewhere in the crowd there's someone that hardcore Foundry then you can do it uh wag me uh is

basically like a um you know plugin for uh react or you know basically SDK that allows you to uh interact with the wallet connection that you have so we use that and then also typescript so everything's written in typescript typescript is kind of like the way to go this day like an age like if you're going to learn uh how to build uh adap I would recommend starting with typescripts just because it's got the type safety and it's just a little bit more intuitive but you can write stuff in JavaScript so don't be afraid if you're like I only know JavaScript that's okay and if you don't know JavaScript at all or typescript at all that's okay too because um you know the thing I want to walk you guys through today is going to kind of show you some

Basics and kind of help you get around to like you know do stuff there's a lot of cool stuff that's already in scaffold e that make it easy to build a UI you don't have to be like a UI Maxi uh you can actually kind of get away with like at least you know building your your smart contract and then plugging it up to scaffold eth so then uh you know the the the version that we're going to be doing today is the subgraph package which is kind of the same thing as all that stuff but then it's also this kind of like middle wear layer so that's that's what the graph is the graph is kind of like a middleware layer for indexing data and I'm going to go more into that and talk about that but basically you can think of it like this like blockchains are

kind of incentivized for rights right so if you want to like secure some data on the blockchain and like update State on something you you know sign a transaction and you submit some value and that's that security is basically empowered by the value that you're sending in the transaction that pays the validators and it's really like blockchains are incentivized for writing but they're not in incentivized for reading so much um and in fact the the the method that you read from like a Json RPC is actually not uh optimized for reading it's really manage like used for managing your node like if you have a blockchain node so the indexing layer is kind of a crucial part of like um the stack because you need something that

can like read all the data from the blockchain and then store it somewhere else and that's that's exactly what the graph is it's a a decentralized network so I'm going to get more into that later but I just want to at least show that okay so I want to start with just doing a like quick overview you guys don't need to follow along just kind of watch what I'm doing so you guys can see the like the value of scaffold e and then what we'll do is we'll pause and we'll have you guys set it up okay so let's do that okay so I'm using a few terminals I'm using t-m which is really awesome t-u uh t-mo is basically a terminal Multiplex just allows you to split up your screen you don't need to use it you can just have multiple terminals open um

so if you see those four and you're confused why there's four that's why but you can just open up separate panels um and that's because you kind of always need a few different Windows to do different things because it is a yarn package you you run these yarn commands to kind of set up different parts so first you want to set up your blockchain then you want to set up your front end then you want to actually deploy and then lastly we want to set up Docker uh so we're need to have these four Windows always open so scaffold e if you go to scaffold eat.io it will take you to the the page for scaffold eth there's really two ways to install scaffold e you can either clone the repository which is here and by the way these are not the steps

you're going to follow today but I just want to talk about it you can either clone the repository or you can run an npx command which is basically like a script that will set it up for you uh it's in kind of a beta state but if you want to use Foundry you need to use the npx command um I would recommend using the get clone in the future just because it's I don't know it's a little bit less beta uh it's a little bit more stable sometimes there's issues with the npx script so I would use the Clone command we're going to be talking about and if you look in the notes today there is a link to the subgraph package here and there's also a link to my workshop that we're going to be going through which is here and this has all the steps we're

going to follow uh and more importantly what we're going to do is we're going to use this subgraph package of scaffold e so we're going to clone the repository and then we're going to check out this special B branch called subra package okay so I've already I've already done this for you so that's why I want to just preface with that um and I just want to show you guys how it works so we've got it all here let's just check real quick we can see that we have a git Repository there's a a package Json which is that means it's a yarn package there is a packages uh folder uh let's look at the code real quick so I'm using vs

code and let's look at the packages folder and we'll see there's three different packages so typical scaffold e is two packages it's a it's hard hat and it's uh nextjs right so it's backend front end so we're going to be setting up a back end in hard hat and we're going to be setting up a front end in next s and then we're going to be setting up a subgraph in Docker okay so we'll get more into the code here a little bit and and a a little bit later but let's just set it up so the way you orchestrate scaffold eth is all with yarn commands the beauty of yarn package manager is you can set up scripts that make easy to follow commands to do different things so to set up our blockchain all we need to do

is do yarn chain it's going to basically start up hard hat for us it's going to give us these these play accounts right these ether accounts that with private keys and it's set to go that's it then in a new window you need to do yarn start so that's going to start up nextjs which is react basically with nextjs on top and it's going to SP it spin it up and run it on Local Host 3000 so this is going to be run locally this is going to be run locally now we have our front end and our back end set up that's it yarn chain yarn start okay next we're going to do yarn deploy that's it so yarn start yarn chain yarn

deploy so with those three commands we basically took a smart contract that comes as scaffold eth we deployed it to our hard hat node we our front end automatically reconfigured for us and you'll see the magic now so let's go to our web browser and let's go to Port Local Host 2000 so we have our front end right running on 3,000 and uh what's cool about scaffold eth is it does come with a smart contract that's like a very basic smart contract and um we'll see here that we're on the wrong Network we can disconnect actually when you guys set it up you'll it'll look like this so it'll automatically connect to what's called a

burner wallet so we'll get to that in a second but basically we have this first homepage which is like kind of like the welcome screen it's your you know your your page uh so it uses nextjs app router so there's a page do uh TSX file basically which is like kind of like an index file that has this main page and then there's these special routes and the first route is what I want to talk about which is SL debug right here so debug contracts what's cool about scaffold eth is it actually takes in the smart contract and when you do a deploy when you when you use hard hard hat deploy um you basically take your smart cont contract and you uh compile it down

into bite code and you push it to the blockchain right but you also generate what's called an ABI I don't know if you guys got into abis the last couple days but the ABI is just basically the instructions so that any anything non you know binary talking can interact with your smart contract because your smart contract is compiled right so what scaffold does is it takes the Avi and it automatically injects it for you into your front end so it automatically knows how to interact with your smart contract so we get our contract address we get a we have a balance checker for our contract we have the network that it's configured to and all of the read fights right read and write sorry functions and we also have our variables all available to us because scaffold e that's that's

why it's so cool uh it just reads all this data in for us so at this point we can actually start interacting with our smart contract if we want to so we could say like all right we want to set a greeting so we can see here that there's a a a right function that allows us to write state right uh that says all right let's set a greeting right now it's building Unstoppable apps so we could change it to herb. eth and then hit send so going to get an error all right do I don't have enough funds to pay for the transaction I'm using this burner wallet which is right here what's cool about scaffold eth is next part is it comes with this burner wallet function which basically is a private key that's

generated inside of the browser so so you don't need to connect any wallet metamask anything the the wallet's ready for you already all you got to do is fund it so there's also a button for that so we hit that we fund the wallet so now we have one eth in our wallet ready to go now we can hit send and we can update the state so it's that easy we just up up and running with two commands deployed our contract made a state change we can see here now that we have our new greeting we have a owner variable which we'll get to in a little bit we have a premium which is like a Boolean that's being checked we'll get to that in a second and then we have a counter that keeps track of how many

times the greeting has been set so if I come over here and say Foo and then I say bar and it keeps going up right so it's it's a smart contract it's very basic we're not going to I'm not going to get to the subgraph section yet because we're not we're not that far um but what I want to do now is have you guys kind of get to this setup where you at least have scaff e running and you're good to go um really quick too let me just show off the smart contract so you guys can see what that looks like so the packages folder again it's it's got two different folders or three different folders the hard hat folder the next Jazz folder first half of today we're just going to be focusing on hard hat so we won't get to the next gesta later so

let's look at the Hard Hat folder and let's look at the contracts folder so inside hard hack contracts we have your contract. soul there's a lot of comments in here that kind of make it easy to to read and understand what's going on but basically it's a solidity file right and it's got the pragma version it's got some variables that we've defined that you that you saw earlier that are you know here uh we have an owner variable we have uh the uh string we have a booon and then we have the counter and then we also have this mapping which there's a lot of different stuff going on in here uh and then there's also events okay events are basically like logs so if I don't know if you guys got into that

much but events are important because we're going to use that in the the scaffold or the uh the graph part of today's Workshop but the event is what's broadcasting all the information that changes and then we have this Constructor okay we'll get to that a little bit later as well but the Constructor is just like any Constructor if you're familiar with JavaScript the Constructor in solidi case only runs at the time that the contract is deployed so we can change whatever we want at that time sorry this is kind of going in out and then we have these modifiers which we'll get to that a little bit later but that's like a check basically a modifier is is a function but it's just called a modifier because it it you can run it as a requirement for another function but anyways you get the idea

it's a really basic smart contract you can you know solidity is pretty easy anyone who's written some programming language probably can learn solidity pretty quick um so you guys can probably glance at this and kind of make your own decisions but uh let's kind of go into the setup so so today we're going to be following the um subgraph package full stack dap Workshop so it's a it's a it's a repository you can go to bit. lul stack dap okay and that's going to take you to my G my GitHub I'll leave this up for a second

so bit.ly stackd there is a video so if you guys for some reason get lost today and you guys want to follow along later there is a video here which will walk you through everything that we're doing today uh it was recorded in San Francisco but we're going to actually go through it so when you go to the the repository um basically there's the requirements so you probably already have nodejs installed you probably already have yarn package manager you probably have git uh if you're a developer you got to have git right uh but the last one is Docker I should put teamu as a requirement here but it's

not um so Docker raise of hands is who here has never used Docker before okay don't be afraid because you don't need to know Docker um the main thing about Docker is uh it it has a the package that we have in here it has a Docker compos file that does everything for you um you just need to have the docker um binary installed on your machine and you can run Docker compose and install it uh raise of hands who here is using Linux okay who here is using Windows a lot of Windows how many of you using Mac so mostly Mac okay so Mac is the most userfriendly experience for

scaffold Le uh but there are some like caveats with Windows and there's some caveats with Linux uh hopefully we'll just address those as they come but so you guys can follow along so what I want you guys to do is if you don't have Docker installed install Docker okay if you've got Docker installed you can start with this first step so you can come down here where it says setup scaffold D subgraph package okay and what we'll do is I'm actually going to go through it with you guys while we do it so you guys can watch me if you want or uh if you guys have issues then we can address them as they come up so I'm I'm just going to um go back here CD da da RM rf2 let me just wipe everything

out so I'm just wiping everything out rm-rf goodbye okay so I'm going to do this and I'm going to copy paste it in I'm just going to make the directory named a little shorter cuz like I should have done that in my demo but I'm just going to do se2 like that that way it's easier to read when you guys are looking so I'm just going to check out the repository we're just going to go through it one more time real quick cds2 now the thing you guys didn't see me do earlier is yarn

install you can type justar yarn or you can type yarn install so it's going to go and install the dependencies so um you know there's a lot of stuff there's a lot of packages that come with scaold so it's not the most lightweight uh developer experience but it's it's a lot lighter than it used to be so scaffold e 2 is the new version scaffold e one was a lot bigger uh scaffold e 2 is actually pretty lean but we're going to um install those dependencies might take a little while if if everyone's downloading the packages at the same time it might take a little longer right cuz we're probably chewing up the internet speed so we did yarn install so we first we cloned then we did a yarn install now we're going to do yarn

chain right I can spell right yarn chain and then we're going to do yarn start oh got to go into the right directory yarn start and go into this one and do next we're going to do yarn uh start then yarn deploy so yarn chain over here yarn start over here yarn deploy down here so again these can just be in separate windows but you always want to have kind of like three or four windows with scaffold e there we go we deployed successfully now the last one is we need to set up so if you've uh hand show of

hands if you got Docker installed okay so if you're not I assume anyone else is still installing Docker right yeah okay okay so while we're waiting for people to install Docker I'm was going to finish up here with this last couple steps so yarn start yarn deploy oh sorry yarn chain yarn start yarn deploy this last window we're going to start up uh the graph so that's this step set up the graph intergration so when you do these first four commands you'll be up and running with scaffold E2 now what we're going to do is uh set up uh the

graph so yarn run node will do that for us there's a command here to do clean node you only really need to do that if you've set this up before we're just going to do yarn run node so this this last one is Docker so basically you can think of Docker as like an orchestration tool for virtualized containers so virtual machines containers whatever you want to call them uh containers are just like little small versions of either an OS or a binary package and they're running locally so here we're running all the infrastructure for graph in this kind of like virtualized

environment inside of Docker you'll know that everything's going good when it says info downloading latest blocks from ethereum so if you able to see this here that means you have your blockchain running if you see this say ready you have your front end rning if you have uh you know successfully generated your types and deployed to the transaction with the deployment and it tells you how much gas you got that's successful and if you see info downloading latest box from ethereum then you know that's set up successfully okay still running yeah yeah so everyone's probably trying to install

the packages right now so internet connection might be a little struggling a little bit um uh oh you're you're just trying to connect to like the blockchain that's just the blockchain how did you get that where's your terminal at yeah this one I use oh yeah that's virtual subsystem for Linux yeah that's fun hard Hat's running chain and then yeah is that yeah that's uh that's okay yeah so now open up a new terminal so now you need a new terminal and now you can go into the same folder and do yarn start same folder of of yeah wherever you checked out scaffold e so scaffold sub

yeah so if you're following the instructions it's going to be inside of this folder scaffold e 2- subgraph package right okay okay okay y so the last next command is yarn start so that's going to need to be in a new window and then yarn deploy is also in a new window I'm going to go ahead and leave this up up for a second yeah it's just loading up your browser just give it a second um and then in that new window to yarn deploy so another terminal yeah so again you

need you really need four teral open to do all this stuff you guys are going to become multitaskers um but yeah anyone stuck this is kind of what it should look like if you're up and run yeah like yours I would like it's called t-u tmux yeah t yeah it's kind of it's it's kind of hard to use I'll be honest but once you learn it it's you'll be an ultra Elite hacker yeah I've tried

but doesn't really look it is yeah so there's a lot of shortcuts yeah uh to it um we can chat later and I can give you some ideas of what I how we set it up properly if you memorize the shortcuts for like the basic stuff pretty easy yeah yeah the thing yeah so you can do like contrl B shift five or like contrl P shift coma like and you can do these things to split the screen up and yeah we can chat later I can show you and we have to CL this one not the or the uh yeah yeah so you might want to

just go to bit.ly stack. so go to yeah bit yeah go to the URL uh right no no no no no actually it's right here there you go yep follow that one yep the I think doctor compos like this a dash but I remember when I installed for some reason M mine is without a dash okay where is are you running Linux yeah what where is the the script so that I can change it yes who here is joining

Linux few okay you guys might want to pay attention to this so I T I mentioned briefly that scaffold e is a monor repo so it's a yarn monor repo so you have a package Json which has all the scripts here right and they reference the monor repo script so because there's workspaces so inside of the the packages folder here we have a hard hat and we have another package Json so then these are the scripts for this one so if you're so uh in this case we're using uh the subgraph package so we can go to that package Json and we can look at the the the command that's being run when we

do run node it's doing here CD graph node and Docker compose up so for some reason you've installed Docker and the command for Docker is not Docker Das compose uh for Docker compose it might be Docker space compose you might have to edit this so there are these weird little cave caveats with different operating systems I apologize but we'll try to work you guys through if you have issues but that's that's important to understand that you know that's kind of how um the monor repo Works main package Json is here and it has all of the scripts for you and that references the other workspaces that you have right

here so if you're trying to troubleshoot something with a with a yarn command that's where you go okay anyone else stuck but here it says method not supported that's okay yeah that's normal that's like a I don't know why it's doing that but it does that lately so to do with evm but yeah you should be good yeah okay is anyone else stuck okay raise of hands if you have gotten to where I was at few of you guys

okay raise of hands if you need like some more time yeah okay yes uh seem to compile maybe it already failed to get chain 95 back on net version can I connect to the Network

Global host that's weird I connected to I I put y this is Young oh it's okay that one's running yes it's running is it running in Linux uh this Windows sub system Linux this is the the code that is connected with the M yeah I feel like it's not able to connect to Linux Local Host for some reason so um let me think real quick windows

[Music] don't yeah so so in my like my workshop I describe a bug here which is with the chain so here it is okay so if you need to open up am I does this on test one two okay so if you're running Linux you need to go into your package Json for hard hat so you need to go into a hard hat so packages so packages hard hat package Json and then you need to look at the chain command here so because we're running if you're running

Linux sorry if you're running Windows Windows yeah with Linux there's a weird like issue with networking where you have to broadcast on 0.0.0 to be able to access it inside of uh other N I think on Linux 2 yeah we can we can let's let's figure it out as we go if you have an issue where you see like unable to connect a hard hat it might be because you need to add this command so it's in the it's in the workshop if you scroll just a little bit further to this part and it's the hard hat node-- Network hard wet no deploy and you need to add this-- hostname 0.0.0.0 so try to add

that to yarn chain and then restart your chain so you're going to have to rerun uh yarn start or yarn chain sorry after you add that so you can go come in here you can add it to the back of uh chain like this save it make sure you save the package Json and then restart your chain okay so again that's in the read me it's going to be you know you've probably done this part you did the install you did a chain you did start and then we did the deploy and then now you want to set up the graph right um as you can see

it's running it looks like it's working for me but we have this run node you might get an error about that it cannot connect to Docker so then you need to add this host name right here to this package dayon in packages hard hat okay um and then you need to make sure you stop down and restart with yarn chain you also might need to allow firewall access so if you can this is not best practice but turn off your firewall turn it off for right now No One's Gonna hack you just turn it off we're in a secure environment we're all friends all right is anyone stuck anyone

stuck no just people are still working yeah oh cool awesome cool we got so raise of hands if you think you're good at this point downloading latest blocks is anyone two I saw a few people okay so people are still thinking is it working okay awesome all right is anyone stuck anyone stuck no raise of hands if it's working okay so some of you guys are still working you need more time you need like five more minutes to yeah okay

yeah that's um yeah that should be good I think it's good I think that's right yeah yeah that's right that's been one one com that didn't yeah that's okay don't worry about it that's for like later if you want to restart everything you need to clean up all the old data so it kind of wipes out your data it I'll explain it right now so just so you guys know too there there is this yarn clean node Command right here yarn clean node that just basically is cleaning up old data so let's say that you've made changes to your smart contract and you want to wipe out all of your graph node

data that's why you need to do that so the first time you guys don't have to worry about that we'll worry about that when we get to it yeah either one whatever you like what do you prefer yeah I like doing in my own terminal because oh sorry I'm sorry I don't like the vs code terminal but that's just my [Music] preference

are you using using Windows yeah so you need to be is that Linux inside of Windows yeah I haven't seen that oh yarn not installed you need to install yarn so Google uh install Yarn yeah you need to install yarn package manager uhhuh where what file I have to modify oh it's the package Json inside of packages hard hat so you have to do this before yeah don't worry about that we're going to worry yeah you can kind of skip that command yeah so if you load up the okay

looks like you're you got a deploy working okay cool yeah so now open up the project uh you have like do you use vs code or use VM or what so go to packages go to hard hat and then go to package Json there you go and so it's the chain one you need to add the host name you guys good okay okay all right we we'll we'll we'll let everyone catch up because I think it's important that everyone's caught up so if you get stuck let me know we'll give it like five 10 more

minutes from the terminal uh and I try to run this command this one so you can see one uh and when I try to say it already has uh everything inside but it's empty so I find another create another one but I just clone this one not this that Comm oh yeah you did this one yeah um well it's called subg grab package it's called it's actually named yeah cuz this I think I think I had to name it something else don't I go in the my my read me no it's the same it is the same package you can use it but I have you name it scaffold e 2- subgraph

package name no I'm telling you that that's what I had you check it out as so it shouldn't be existing that's what I'm trying to say so here let's do this um load up your terminal where's your terminal at over here oh you don't you don't you don't need to do that that you can just do it um yeah do here all okay yeah so now we can do just paste what you just copied yeah grab that this one because the other one didn't work on Windows let's try it already exists onor let me see real quick okay let's do this LS

LS can you move this over so we can see it [Music] uh so in this folder boot camp this one there are four other folders ah okay and maybe inside this ones something weird is going on with your with that yes that is only it's something with the naming like it doesn't like the extra Dash or something try try doing it like this here uh paste it in again we'll go back to the folder folder maybe I can do something different one time

another okay you had a question see if you can try a different folder yeah you had a question we he observed that your terminal the one where you RAR stda while ours just no no no that's okay process yeah yeah yeah yeah okay you got a question um I have problem so I done uh blah blah all this part okay and start this I have problem so I done this mhm you did that yeah I did that so here okay yep you saved it yeah yeah yeah

yeah it's all and after Yin again yeah you got restart your I restart everything start do everything do this and try this okay don't worry about that cuz we're going to get to this in a second so okay show me what you got though you get an error or what yeah so this is it's probably CU start and then I've done the uh deploy yeah deploy yeah so it's okay but after one run node oh Docker compose so do you have Docker installed y do you have Docker compose installed you might have to download Docker compose I I'll mention that right

now yeah one sec one sec all right if you if you guys um are having issues with Docker compos in Windows sorry obviously I can't type inside my password at the same time uh install Docker compose so do a Google for like install Docker compose Windows Linux subsystem uh you might need to um install Docker inside of Linux um so that you have the docker Das compose command so it's probably here yeah so these are probably the steps you need to fall that's if on a boonu I think it's auntu yeah WSL auntu WSL right is that the version of Linux do

you guys know that comes with Windows it's puntu right yeah so this should work so if you Google that just Google like install Docker compose Windows Linux subsystem and make sure you have the docker compose command you can verify by just doing um like docker-compose d-el and see if you get an output or D- version that would work too but you need to have the docker Das compose available if you want to use Docker uh and we need to use Docker if for some reason worst case you've at least been able to to deploy your contract using yarn deploy that's the biggest important

thing if you don't get the the docker running don't it's not the end of the world because it's not part of your Bounty so you guys can skip that part okay yeah send say um that's weird it's not getting it's not reading anything oh you know what did did your deploy work yeah it did right yeah that's weird it seems like react can't reach this is Chang this is start do yarn deployed uh over here yarn deploy uh space uh Das Dash reset no

dash dash dash dash Das try it again you have to put something in oh it it's working though yeah okay thank you yeah yeah yeah and I i' have to do this m and a new window yeah it's okay if I do that okay yeah so yarn start are you in the right directory though yeah there go yeah you just have to be in the same directory that you had scaffold e and then then open another one so now I for MH y yeah let me know if you get stuck okay yeah you have one more

question uh so I compos now it's working this ISC local create and show me the so let's worry about it after I get to there okay I I'll see if I can figure it out yeah yeah yeah yeah let's let's figure it out when we get there I think yeah okay raise of hands if you gotten your contract deployed your smart contract okay raise your hand if you've got graph node running in Docker okay raise your hand if you're completely stuck

still stuck you're you're stuck okay so a few people and still playing catchup yeah to do yarn install yeah it's okay that's normal okay that's okay I think what what we'll do at this point is we'll let people catch up on their kind of intermate time I'll help people as we go but let's let's kind of go into the next part yeah we are in in the right condition if we match all the three yeah okay yeah so let's let's let's think about this like a a a test this one is where 25% this one is worth 25% this is worth 25% this is worth

25% if you're getting 75% you're a c and you're going to qualify for the hackathon if you're failing on this part and Docker is not working because you have Linux and windows we'll try to get you up and running but don't stress about it okay what we want to focus on now is these three things we're going to talk about the graph but if you've made it through these three and you're got these weapon running you're able to do deploy you're golden okay if you're having problems with Docker that's okay and graph node that's okay you're going to learn something today but don't worry about you know don't worry about it okay so let's uh all right let's uh have everyone kind of listen in now okay

we're going to go to the next section okay I want to talk about the graph uh first of all okay so the main concepts for blockchain right are blockchain smart contracts frontend decentralized front-ends right static content like HTML JavaScript CSS that can be deployed on a decentralized file f file sharing protocol like ipfs or R weave okay but the the other part the data is that is one of the hardest things to solve because there's lots of data right I think we all know that in Information Systems in there's just a lot of data so you can't store this data on chain right

so if we think if we know about smart contracts and the basics of what they're doing we'll talk about ethereum because this is an ethereum hackathon ethereum is an ethereum virtual machine it is a state machine it's the main purpose of ethereum is to deploy smart contracts that have a state and then allow them all to come in a consensus on changes to that state Okay so smart contracts if we look at like an example like Crypt punks right all it is is a state of IDs so all the IDS that are Crypt punk nfts what their current owner is which is also a state what their metadata URI is which is you know nft lingo which you don't

need to know but that's like all the aspects to each individual nft where that lives but really all of all an nft contract is is three different things are going on there's transfers there's approvals um and there's owners like you know there's some State inside of the nft contract but really it's a data it's just a data object right so we try to just put exactly in a smart contract what should sit in a smart contract that's like important for security so like an nft a crypt Punk who wants one anyone want one they're worth like I don't know 100 eth or something I don't even know but my point is is is that like the owner is

very important because if you own the nft you own like the 100 eth that it's worth so that's something you want to put on chain the metadata URI is probably not as important because it's like the picture and it's like the traits of it you know yeah it is important for it to be somewhere but it doesn't need to be on chain so anyways this stuff changes right like State changes just like any database has database entries that get updated State changes you propose a transaction to transfer a crypt Punk like if I'm going to send one of these guys in this in the stage a crypt Punk I'll send it to you that gets initiated on the blockchain and what happens is an event is created like an event says okay cool this person

approved this transfer and transferred it to this person for maybe maybe you transferred it to an exchange to sell it or maybe you transferred it directly to someone's wallet either way an event is triggered okay so that's important but there's a couple problems with blockchain data that that we're trying to solve with the graph and the first one is there's a lot going on there's like so many so many people are competing for Block space right there's tons of of these daps these protocols smart contracts trans transfers going on there's all sorts of stuff and it's very difficult to read because it's all usually in like bik code uh it's very hard to understand if you were to look at like the block and

like download it to your computer you'd be like I just don't know what to do with this so that's the first problem it's a it's messy the blocks are messy and there's a lot of them the other problem is I talked about it earlier is blockchains are not incentivized for reading data they're really incentivized for writing data okay so if you want let's say you wanted to read all of the crypt punks there's 10,000 of them you would need to make 10,000 separate calls for each individual Crypt Punk and then you got to have some place to store that so you'd have to have your own database or you'd have to have somewhere that to put that and then that's only going to give you the current state it's not going to give you historical state right so that's that's some of the problems that you have to

deal with making 10, 10,000 Jon RPC calls to the blockchain would take a long time like it just doesn't make sense for you to do that in your front end so that's a problem also Providence I talked about this is like you can't really know like what happened at any particular point in the blockchain unless you query that exact block so that can be really messy to deal with um because you have to know the exact block number which block numbers are numbers and they're they have a time stamp kind of related to them that's somewhat accurate but it's very hard to get the data you care about uh in that you know going back in time so what we see is like stuff like this where it's like people are trying to get like in this example it's

someone's trying to use their front end to get an address uh from the wallet Loop through all of the nfts in the person's Wallet create an object on that push all the data into that object and then print that data out so this would basically be fine if the user only had like one or two or three nfts but the minute that they have like 20 or 40 or 50 nfts each nft would maybe take like 100 milliseconds right you can see the problem here the page time would just drastically performance would drop so that this is a real actual person that was trying to do it this way it was not ideal right so this is where the graph

comes in so the graph is it's a separate kind of network decentralized network of indexers that that's all they do is they index data and make that data available to Consumers okay um so it serves about 1 billion queres per day but the idea is to take that same mess of like all the blockchains and organize them into separate buckets like databases called subgraphs okay so a subgraph that's exactly what a subgraph is is it's an organized data for a smart contract right or a set of smart contracts so what we can do is uh the graph is powered by graphql who hears

use graphql Okay graphql no Okay graphql is awesome first of all uh I mean we are in Facebook meta so they're like the creators of graphql um it's a quer language that allows you to spe specifically query for exactly what you want so if you only care about the nfts ID token ID the metadata and their previous owners you can specifically ask for that data and you will get only that data back so it's a query language that is highly customizable and highly performant right it's optimized for front ends because you can just get what you want and then you don't have to like do this like crazy parsing and you know

filtering inside of your app you just filter based on requests so this is what we want to build with subgraph package it's just the same stack it's it's nextjs front end blockchain and hard hat or Foundry and then indexing protocol is the graph which in this case we're running everything in Docker okay so what is a subgraph exactly like technically so this is the this is probably a little bit more deeper dive and um the main idea is that there's really three configurations to a subgraph the first is the Manifest which is kind of like the main main configuration file it's basically

telling uh you exactly what network you care about so if you're on a connect to ethereum or in this case arbitrum or and then also what protocol you care about or what dap you care about what smart contract so in this case we uni swap right and that defines like where the data sources come from from and what you want to actually query yeah if this it contains like the API of the contract that's a great question yeah so the the Manifest ELO does read in the ABI because it um just like our front end needs an ABI to be able to interact with it like that's what scaff does the graph also needs an ABI because it it

needs to be able to decode the data as it comes in so that's a great question and we'll we'll look at this a little closer but that's that's that that does have the AI in it um the next one is the entities so I know graphql is new to you guys but the the way you organize data in graphql is based off what's called entities so entities are basically like key value stores so like data types and how you want to store those so the graph is powered by postgress and graphql so all the data is stored in postgress and exposed with graphql and so if you want to store this data in a specially organized way in a subgraph you have to

Define exactly what data types you care about and how they should be stored in what structure so that makes you able to your your your schema correlates directly to how you query data and how you receive data in those kind of objects and we'll we'll get closer into it I know this is probably a little uh deep but we we'll actually show it in the real world and then the last part of a subgraph is the wasm module who here is familiar with wasm no okay so wasm is just web assembly so it's compiled down um optimized code I would say like secure wise is very secure um and particularly a subgraph the the uh wasm module is

written in assembly script which is a subset of typescript so it's basically typescript like if you look at it you understand typescript or JavaScript you can understand what um this is and this is this is kind of like we I call it the runtime this is what's like processing all the data so these three files together are deployed on the decentralized network so the graph is a decentralized network there's over 200 indexers that are running all over the world and if you deploy a subgraph you take these three files you package them up and you send them off to the graph all the indexers say okay cool I'll pick up these based on you know whatever um incentive that they have which I'm not going to get into any of the tokenomics

or HRT or anything like that but I just want to talk about the technical functionality and these are what you need to build a subgraph okay any questions about this before I go on and I I I will again preface this this is kind of like a learning module for you for the graph you don't need to use the graph in your project but this is all really good information especially if you guys are going to stick to web 3 um and the graph is really really useful any questions no okay so the basic concept of the graph is basically to take event data so logs right things are going on inside of a contract we care about that data or maybe you have offchain data so maybe

you're storing stuff on something like ipfs or R weave which are both decentralized file sharing protocols so you might have like static files like maybe you have a B on object that you store in R weave and you want to ingest that into the graph well you can do that with data processing with the graph because you have your your assembly script which is your WM module that basically listens for these events or or can query these decentralized protocols and then take that data in process it how you want right customized here in assembly script and store it in postgress right so that's what the indexers are doing behind the hood and then the consumers

right that want to consume that data they make a graphql request with exactly what they care about graph node which is part of the decentralized network it's a it's a it's basically an operator that runs on the stack go does a query against the data that's been stored gets the response and serves it in graphql so here on the back end this is all done behind the hood it's SQL but for the user they get that pretty cool experience with graphql where it's easy to read and write or easy to read so again three configuration files mainly that you need to deploy a subgraph all the processing is done with WM in this

kind of runtime environment store events are stored offchain or sorry events are pulled from from a chain processed with the assembly script and stored in postgress and then for for visualization for the uh the front-end consumer this could be like this could be a Dap this could be a like a front end like we're building with scaffold e it could be like some kind of data scientist right that wants to get interesting data it could be anything any kind of consumer and then the data stored in post grow any questions does it make sense yeah yeah on the first slide please uh the last

ref the Manifest where is this one last this one it translates data from your data sources to the entities defined in the schema so in the manest yeah so you can think of like this manifest is kind of like it's a yaml so everyone know like who knows yaml yaml is cool because it just like organizes like configurations for you right so like that's exactly what it is it's like okay I care about this Network I care about this smart contract I care about these data types and it references all the entities in here and it also references all of the processing in here they're called

handlers they're called handlers M yeah yeah data and we just request to sub with the and the data that will be read is from the blockchain it's originally from the blockchain and then it gets ingested into the graph then sub starts indexing all this stuff then we can use it yep that's pretty cool yeah it's very cool that's why I work here okay so let's let's show it in practice oh one more thing so this is kind of this like same idea I talked about earlier so you have

a Dap right you have your decentralized application that's maybe you're probably running in like ipfs or R weave you still propose transactions to the blockchain by signing it with a cryp cryptographic key and making a call to your smart contract your smart contract fires off events which are like logs graph node is like the Workhorse for uh the graph Network so this would be an indexer running graph node picks up your configuration listens to the events it runs the WM mod module stores that in postgress and then your dap just queries the API right that is also exposed to

graph node does that make sense yes so the events guarantee that thees are always updated MH Yeah question listen to all the events that or only the one only that are configured in the subgraph so yeah so imagine like and I just want to give you an idea of what like if we look at like the graph sorry if we go to like the gra.com and we go to products and we go to Explorer someone name a protocol does anyone know web three protocol Unis swap okay no it's the first one they're our

biggest customer I would say so there's already a subgraph for uni swap someone has written it already there's all these different versions you you can query it directly by using the uh the network so there's a a API for it you have a query URL you can generate an API key and you can query it it's already set up but there's a playground here that shows what the data looks like so I can hit play so here's my query so in this case I wanted to get all the factories or should say I want to get the first five factories that are available and the bundles and then it gives me the data back so it's quick query exactly what I want exactly what I need with that

query I know this is hard to read let me just zoom it in real quick does that make sense so that's the power of graphql and graphql runs on the graph Network like that that's what we use what what are we seeing here what id so what we're seeing is uh so the ID is is probably um it's a good question it's probably the smart cont contract address for another protocol in this case you can set the ID to whatever you want in the subgraph configuration if you want the ID to be someone's name you could figure out a way to do it but the ID in this case is probably a smart contract address I it's a Unis swap Factory address so the way Unis swap works is

it's like a sub it's a contract it's a contract and then it's a subcontract that is deployed through the factory so every time there's a swap on Unis swap there's another Factory is created or another smart contract is created so this should be the address for this particular Factory we could look it up and see what it is but it's probably some kind of pair or something like that okay anyways I just want to show you what that looks like you can also see if it's up and running and all that good stuff but let let's continue on let's let's get our hands dirty a little bit more okay so I want to do a quick check so who here is stuck anyone stuck no cool I know we haven't gotten

to that part yet so let's just try to go there first uh do anyone stuck no okay let's just continue on with the the workshop and I want to show The Next Step so we've gone ahead we did the Clone we did the install we did the chain we did the start we did the deploy you may not have gotten to this part but if you did yes run node hopefully you got run node working if you had Linux you probably had had to update this host name to this uh package Json uh you may have had to open up your firewall if you haven't done that do that if you need to but now we want to talk about our our subgraph so let's go back to the subgraph configuration so or the

package so we we showed the contract here right and what more importantly what's important is the event right it has an event it's called the uh greeting change so every time we change the greeting it shoots off the who sent the greeting what the greeting was as a string what whether there was a Boolean true or false and whether it had any value so did it have any value in the in the transaction because you can send a transaction on a contract that doesn't have value or you can anyways okay so we have an event and if we look down here at the greeting we also admit that event so that's how events work you define an event and then you emit the event when something

happens so we want to emit that vent which we do and cool but as a front-end developer how do you get access to that well you would have to if you didn't use the graph you would have to go and query the RPC over and over and over and over to get all the events so it's fine if there's only a few events but you have hundreds of users thousands of users thousands of events per second it's not going to scale so this is where the graph comes in we've already talked about that so now let's look at the subgraph okay so out of the box the subgraph has everything that you kind of need to uh to get going basically it's it's already written for

you so that's important to know because um we can look at the subgraph yl first so I talked about this earlier this is the it's called the Manifest so it has the address which is what is deployed earlier when you did a yarn deploy it automatically P pulls it in the network is local host cuz we're running everything on local hosts and the entities are here greeting and the sender so in this case that's the cool thing about graphql is you can create as many entities as you want and store them however you want so in this case we're keeping track of all the greetings as one object one like database table we're also keep tracking all the senders as

another database table and then we can link them together which I'll get to that in a second then we have our ABI so the ABI we talked about earlier is kind of like the the map to our smart contract so that it's human readable so if you want to be able to like understand what's going on we have that injected automatically and then we have the event handlers so this is the mapping the the the wasm module so it points to a specific event so we already showed the event earlier it's called greeting change and it has an address string a Boolean and an unsigned integer and then it has this Handler so basically what the Handler is

is like all right every time this event happens run this or do this okay so as you can see this is telling our subgraph exactly how to behave it's telling us where to look what events we care about what data types we care about inside of the entities what kind of um wasm we're going to use what kind of API version all that stuff right it's pretty much the high level overview of our configuration right then if we yeah actually emitting the after it is yeah because if we look at the at the packages hard hat contract and we look at the events it is the

right here address greeting Setter and we go here it's the message center what is the index index in the what would it index it as uh we we'll show you in a second let's get there yeah so okay so we we showed the subgraph animl inside the source directory there's two files okay there's the schema and the Manifest so we have the we already did the mapping let's look at the schema real quick so in our case I talked about it earlier graphql we can organize the data how we care about by the way this is highly relevant to web 2 stuff so if you guys

are even going to get a job in web 2 this is very important um we can organize our data however we can't we want based off the data types so in this case we have a type called greeting and we have a type called sender they're both entities which means they're like database tables essentially and they all have all the data types Dei defined with their keys and the value right so we have an ID sender greeting premium value created at in transaction hash the the key thing here is our sender list which is just a database of all the people that have signed transactions uh and sent the greeting has this greetings object here with the derived from field so derived

from allows you to to create a relational link between two different data type or two different entities so here we can link these together so that if we query this sender it will give us all the greetings he's ever done in a database Lookup All Through postgress happens in the back end it's very efficient super powerful so like relation relational data is super powerful yeah oh comments uh I think I don't You' have to Google how to comment graph Q all I

don't know how you do that actually um I probably should know that but I don't this one doesn't work just like a pound sign oh here we go quote quote quote try that okay so UMES that make sense does this kind of like data object idea think of it like a database you this is the database right the entire database table these are the the values we care about in this case we have two different kind of objects

right okay so then next thing is the the how the data is processed so in this case this is probably the hardest part of subgraphs uh just because in general um you know it's typescript basically it's assembly script which is a subset of typescript so it's really easy to read and it's actually got all the type safety that you would get with typescript so you can kind of poke around and look around and see what's going on inside of here but for the most part you can understand that what we're doing is we're importing how to deal with specific types using this graph TS uh package which is already installed if it's not installed there's commands

in the readme to install it but you need to have graph TS installed this allows us to to Define what kind of entities we care about or sorry data types that we care about so in this case bigin and address is what we're importing and then here we import the contract so we need to import the contract so that it has all of the um the types for the contract so that we know how to interact with it and then we also import the schema which is what I just showed you guys the graphql schema which is this because we need to know how to store those data types and then you it's just it's just a function so it's it's always running right every time an event fires off it

runs runs runs right so it's you can think of it as just a always running kind of methodology so it's listening for events it's doing things like creating a sender string based off the event parameters that come through here here we do a conversion to hex string so that we can properly like convert it um um we load it if it exists if it doesn't if it's null then we create it and set the creation date so here's where we actually create the very first sender so if I'm the first if if I'm the if it's the first time I've ever hit the smart contract with a with a a greeting it would put me in the database right it would put my address in from the event

parameters it would give me the created at based on the time stamp of the block so when when it happened what was the time time stamp and it would set my greeting count to one because it's the initial first one otherwise it would increase my counter to two so it's it's it's pretty easy to understand you don't need to really understand this too much but it's just good to understand that in this case there's one function that runs and at the very end of the day we store all the information for the greeting and then we save both of them so do save basically takes the data that we've stored into the um into the function call and puts it and pushes it to the

database okay yeah what is the generated folder the generated folder is like what is run when you uh run one of the generation commands so we haven't done that yet that's why it's showing errors so you see how it's all squiggling I'll show you right now so if we go to the instructions where are we okay um so first of all I want to do local create so I know some people are probably not been able to do this but that's okay we'll take a break and see if people can get caught up in a second um by the way how long have we been going right now like an hour we'll take a break soon too so you

guys can but okay so we want to do a yarn local create so the reason why we're doing local create is we have to create the very first configuration for the um subgraph so you basically like when you do this it creates a subgraph inside of that Docker container as you can see right here over Json RPC and it creates the name of the subgraph and how to uh query it so in this case Json RPC so you just need to do that one time after you do that you won't need to do it again and then we do yarn local ship so again we already have a subgraph that's written specifically for the smart contract we have the smart

contract we haven't made any changes to it's out of the box same goes for the subgraph it's already written for you you just need to deploy it so we're going to do that so learn local ship this is where we run now if we if we look at this command uh and what it does it basically does the generation so it generates all the types for the that we need inside of our assembly script because you know we had those errors before that were showing up here now you can see they went away because we had to generate the types so generated the types and um it also um what else does it do it uh compiles down the bite code or sorry it compiles down the wasm into an actual like binary format because it

needs to be compiled um and then it injects the AI and kind of tests it it it it does a sanity check to make sure that your config is fine if for some reason you made a change it would tell you like oh you have an error here and it does some linting like it would tell you like how to fix that error but in this case it's good to go and it should be good to go so we're going to do 0.0.1 so the reason why you have to put a version is because like as your smart contract changes your subgraph is probably going to change too you add a new function and a new event you need to deploy a new version of your subgraph probably because you need to add those to your subgraph so it you always kind of like match your version to what

version of your subgraph or smart contract so we're going to call this to zero 0.1 you could also just put one you could put 99999 it doesn't matter uh but in this case we're going to do just 0.0.1 because that's what it recommends and it's going to deploy so now what it's going to do is it's going to um give us a URL for our data so now we can open it up here okay and here we go we get a graphql browser so now we can say okay let's do a query

now what's cool about graphql is because we have a schema we can inject that schema which it does automatically for us and we can explore the data because we already know what the data is going to look like and it's a query language so if we click this explore button it gives us all of the data available to us so we can say all right well we let's say we want to get all the greetings and we want to get the first sorry first five Greetings or 10 greetings we want to get back when they were created what the greeting was its ID who the sender was what their address was and hit play uh that didn't work I don't know why I guess oh I redeployed so let's

send a greeting uh connect wallet I'm already connected here so let's say hello. eth and send all right cool so now I can go back to graphql hit play again and there it is so just like that I sent a a signature on this smart contract changed the greeting it ingested it on the back end and it gave us all the data in the response okay so what I'd like to do now is take like

uh maybe like a 10-minute break 15-minute break that way you guys can like either work through your problem if you want or go you know use the restroom or do whatever you want and then when we come back we're going to go through into a little bit more depth into the the front end um and kind of how you can start building your DB because um I also want to kind of arm you guys with like a lot of front end stuff by the way who here would consider them a frontend developer raise your hand okay don't be afraid few of you guys your frontend so that's for me that was the hardest thing when I first got started it was like okay I wrote some cool smart contracts like how do I get my front end to hook up and scaffold e has a lot of stuff that makes

it easy for that so what I mentioned earlier is like don't be stressed out if you don't get this graph stuff working it's okay you can just kind of live without the graph we're going to kind of shift focus and try to just teach you some front end stuff after this but I will help you guys if you want to get up to this speed uh so yeah so let's take 15 minutes if you guys want help right now I can help um and then we'll keep going okay cool test one two test one two test all right can you guys hear me okay all right so all right we're going to retract a little bit um let me zoom out here I don't know why this is like okay what I want to do

uh real quick show up hands who who who got all the way up and deployed a contract with scaffold eth who here got all the way to graph node also got graph node working and indexing and seeing the events and graph ql who here is still stuck couple people are stuck okay so that's good we're in a good state right now okay so what I want to do at this point is I want to uh kind of retract a little bit um and I want to I'm going to do a little bit more like just kind of freestyle here just to show you guys some stuff uh and you guys can take notes but this is all documented um we're not going to use the graph anymore because there's no Bounty for it I don't

think it's critical that we kind of dive into that too much more I want to focus on the front end stuff and I want to focus on scaffold e and how I can like position you guys to make something cool okay so I'm going to reset my Repository um just wipe it out you'll get pull I think there was like an update while I was here okay yarn install yarn chain oh I'm going to do yarn deploy or yarn start yarn deploy I'm just starting over I'm like wiped everything out going from scratch getting this environment we're not going to use the graph anymore if you if you struggled to get the graph

working and it's not working I'm sorry if it's working that's awesome because next hackathon where the graph is has a bounty you can knock it out of the ballpark but let's go here let's take a look at scaffold eth and let's kind of just like do some some winging here so first I want to bring up my smart contract okay I'm going to go into the hard hat directory go to contracts go to your contract and let's just do like something simple we're going to do like a simple change so inside the Workshop one of the steps is we actually go through and show you how to add a new function so here we have this thing that like uh oh wait this is the wrong thing sorry where's it at here it is uh we

have you go in and add a new um event right so let's do that let's create a new event I'm just going to copy this event code over here and we're going to put that right down below this modifier okay so here we have a new event called send message which basically is taking a from address and a to address and emitting the string that comes back from the uh call data and then we're just emitting that Event Event Event data so it's it's it's easy it's just an event a function that and that actually all it does is admidst the event very straightforward very simple use case basically what I'm doing is I'm sending a message on the blockchain there's other ways to do this but this

is just you know you wouldn't do this in a real world scenario but this is just a way that we can kind of just test and see what's going on so let's save that and now let's redeploy now one of the things you might not might may now saw is you can do yarn deploy reset reset will kind of like force your contract to constantly get deployed so if you want to force a new contract you can do that as many times and each time you do that you're going to get a new contract address right so if we go over here to uh scaffold eth and go to debug contracts we can see here that our contract has been deployed if we do it again and come back over we'll see that we get a brand new contract okay so reset is just kind of like a good way to

just reset everything from scratch okay let's grab some funds from the faucet and now we have this new send message right now we have this new way that we can send a message let's send a message to vital. eth everyone know who vitalic is uh he's the creator of ethereum or one of the creators let's say hello what's up dude and hit send so I send it transaction there was an event that fired off cool cool beans it's just a really basic um example of something you could do with a with the blockchain so um now what we can do is we can say all right um we're going to skip over the graphql stuff because we're we're not going to do that right now but these steps are very valuable in the future if

you are at a bounty where you can like do use the graph this will show you how to create new entities how to create a new configuration in your subgraph yl how to regenerate the ABI and the code gen and create the uh the mappings so edit your assembly script so this is a really good thing to go through on your own free time I just want to save time to to give you guys some value for the hackathon so I'm going to skip over this stuff and then it shows you how to ship the new version then you'll get a new version what I want to show now is like let's just say that we have our smart contract to the point where it's running on my machine but now you want to publish it to ARB soia okay um who here installed metamask

and has like a metamask installed all of you guys almost okay inside the link here I put a telegram Channel if you want some uh arbitrum stoia eth I've already bridged like a bunch of eth and I can give you guys some I can send it out later because you're going to need it for deploying so you can join this Channel and there's a um there's a special channel for herb eth boot camp just paste your address in there and I'll send you guys some okay um you can go and get it yourself it takes a while because you got to you got to go to a sapoia faucet and then you got to bridge it so it's a little complicated I can just send it to you uh I've already done the bridging it's going to save you some

time so join that um but let's just say you are me and I'm hacking and now I want to take my smart contract and I want to deploy it I've tested it locally I've been able to come in here I've been able to send a message cool everything's great what do I need to do well at this point you're all locally so what do I need to do first first what we want to do is hard hat comes with these 20 accounts right these are like 20 private keys that are stored there but they're shared everyone uses the same private keys so when you start deploying to a test net or to a mainnet you don't want to use those private keys because the minute you try to fund an account with some eth to pay for a deployment it's

going to get drained there's there's people watching and constantly checking those private keys and the minute there's any address that has any funds they just drain it instantly so you need to generate your own deployer okay so you have your you have your wallet that's in metamask right or maybe you downloaded another wallet but whatever you have your kind of like user wallet you need to generate a wallet on your local machine for hard hat to use to deploy your smart contract so what we can do is do yarn run generate and what this will do is it will generate a new wallet for you and store it the private key in an environment variable inside of the directory for you and it will give you

the address so then you can fund this address okay you can also run yarn account and it will display your account QR code so if you have a wallet on your phone like in my case I could take this I could load up my punk wallet if it loads and I can do a scan and I can scan it like this and I get the address in here and I can send some e so it's really useful for like funding the wallet or you could just copy the address here and fund it so I'm going to take this address for this this wallet and I'm going to come up here to

metamask because I already have 29.9 eth and I'm going to send to this address that I just copied 0.05 it's plenty it's $140 in E and hit next make sure you're on sepolia um so I'm on arbitrum seia right now that's where I'm sending it here so if you want to add arbitrum sepolia you can go to Alchemy and there's a way to do it through Alchemy you can also just type it in manually um if you just Google uh add arbit from sapoia to metamask it will give you the instructions on how to do it um yeah it looks like there's one here

this one will let you do it um there's a lot of different ways to do it scan as well yeah you can do it through what was it ARB scan ARB scan yes so you could do through RB scan there's a lot of different ways to do it you can add it manually whatever either way you just need to have arbitrum seia here so what I'm doing why did send fail uh oh is it the same address no that's really weird I've never had a send fail

uh I don't I don't know give it a second anyways I'm trying to so what basically I've done is I've generated this account uh locally there it goes that's weird I've never seen a filed transaction in metam like that okay so now I can come here and do yarn account again and yarn account with scaffold e goes through and Loops through and like checks all my balances for me so in a second here we will see arbitrum sapoia and there we go so now I have 0.1 eth on there okay okay so I sent 0.1 e and so now I can take my contract we've been doing everything local we've been using hard hat but we've been deploying just to our local blockchain now scaffold e has this cool function where you can just do yarn

deploy uh-- Network and you can say what network you want so in this case we're going to do arbitrum subia like that now it's already got the hard hack configuration in there for that specific string to be able to deploy it to it so it uses things so now I've took my contract and I deployed it to arbitrum seoa just like that so now I've taken it from a machine and deployed it so we can go to the address here we can grab the address and we can go to RB scan RB Scania let's

see oh my internet's like freaking out right now okay so Poli arbitrum and paste this address in and here we go so there's my deployment yeah sorry we have to we have to add the private key G file into metamask you don't no no because you can but you don't need to because you're using the in the this is using a deployer account that runs locally so it creates a hard hat deployer account it's just for your terminal it's just for hard hat if you want to import it into metam Mass so that you don't lose the funds you could but you don't need to yeah it's just a deployer account

it's like a temporary deployer account okay okay so I I generated a deployer account I funded the deployer account I deployed my smart contract to sapoia here it is it's deployed now there's a couple things that you'll notice first of all it was deployed but if we go to contract it's not verified it's just the bite code okay I think I talked to this earlier and we we you probably learned it over the the week bite code is exactly that it's not human rable you can't read it you need to actually be able to like instill some trust in your contract usually that's like the way the guay the guay is to like verify your contract so let's do that yarn verify

there's a command for that Das Das Network arbitrum sapoia now it's going to take my contract oh yeah I had this issue the other day where it wouldn't let me do it um sorry yeah anyway you have found you have you have moved FS to the account you have created here I did it from metamask Yeah so basically I sent I already had some uh funds in my metamask so I sent it from my metam Mas to my deployer that's why yeah sorry for the confusion does that make sense yeah yeah yeah yeah yeah for sure

so for this part this the this thing from so yeah so uh okay again yarn run generate generates a private key for you to use as a deployer locally on your machine so you don't want to use the hard hat accounts because the private key all you guys have the same one it's like your password it's like saying my password is 1 2 3 4 5 uh so you don't want to use that you want to create your own private key so you run yarn run generate if you haven't done it it's going to generate one for you in this

case we already have one so it's going to tell me now you need to fund that account so you need to go your an account get the address for it why does it can't connect that's so weird I have weird connection issues right now the internet's having problems but we need to fund that account if you send me your address here I will fund it for you okay but I would recommend that I send it to your metamask so you can send it because you might generate more than one deployer so so from my MK I have to send that yeah yeah so if you need eth you don't need to do it right now I'll give you guys some eth link later I'm just really showing you like how you get your contract to

arbit you also don't have to verify your contract so if you notice I just had an error there's a way to do it without using the ether scan um I think it's yarn uh so I think it's let's see hard hat verify verify let's see uh r B scan sapoia URL see if this works ah here we go let's try this D- API Das does that make sense okay let's see

if this works uh did it work let me try this I think I need to just remove this right here so basically like what the yarn verify D command does is it takes your contract and it gives the source code to the uh ether scan or RB scan RB scan is basically like a uh block Explorer so it indexes it's kind of like what the graph is but it's a centralized solution it indexes everything and then makes it browsable in a UI the reason why you would do something like this this is because you want to take your source

code and you want to provide it so that they can take the copy of it compile down by the bite code and make sure it matches what's on the blockchain so basically they're just like checking your work and once you do that your um contract will then be verified so if we hit refresh maybe it worked let's see it's not working I don't know why um we need credentials yeah that's probably what it is you're right I probably need credentials to to verify it let's see so in this case 404

um uh let's see just curious that's 200 yeah maybe we do need an RB scan like API key that could be so if you want to verify your again I'm kind of like getting into like nuances here you don't need to verify your contract I'd recommend it because in the in the future it's just a good thing to do uh if we get stuck here that's fine um but let's go home uh let's see if we can arbitrum sapoia oh maybe it's this one let's see oh I know we can probably do with Aly actually so Alchemy is uh like a you know toolkit for they provide like a

Json RPC they provide a entry level like uh weight into the blockchain if you don't want to use like your own node if you want to run your own node so I think you can actually like do it this way let's see API key so you can actually create an API key through them so here's the API key and then you could do the URL let's try this let's just see if this works so we can do yarn verify D- API URL and paste in this one which is with my key see if that works 404 why is it giving me a

404 I don't understand why that's not working that should work okay I don't know either way there is other options so you could um submit your uh source code manually um for right now let's skip over that because I want to get you guys kind of moving on more of the the functionality so we've deployed our our smart contract to arbitrum sapoia which is good enough for you guys to qualify for the Bounty it's been deployed we verified that because we went here and we actually see the transactions um we see that it was deployed 5 minutes ago now let's look at our front end okay so everything I've been teaching you guys mainly has been around the back end the middleware but

now we need to get a little bit more into the front end stuff okay so the first thing is we're not going to touch the the smart contract anymore we're going to focus on nextjs okay so inside of nextjs um there is we we are using we just migrated to the app router so what that means is that there's this app folder and it's personally like it it's a little more intuitive it uses a directory approach to mapping um you know your your Uris your URLs so in this case we have a main App instead of using index.

TSX it's called page so if you're not using operator it's usually index. TSX or TS or JS or whatever in this case it's called page. TSX so the main page of scaffolding e is right here okay and just to show you guys I'm going to load up scaffold e here go to the homepage you see all this stuff here this is exactly what we see here so I'm just going to wipe some of this stuff out let me just show you because this is what I'd recommend you do is just dump all this like stuff just get rid of all this and save it and then that's going to wipe it out there right so this is where this is where you should start Ground Zero

leave this the way it is leave this the way it is you can change it if you want as you get further in your project but for right now you're probably going to need the burner wallet for right now you're going to need to be able to do debugging you know when you start polishing your app you can like move stuff around and get rid of the logos and put it up but keep it like this and then build your app inside of here basically you think of it like an app within the app so build it into that main page yeah we mean yes so the nav bar is inside of the components basically um so components here we have the header and the footer so if we look at the page uh we can

see and I always forget how this goes but there's like a layout and these are the children and then yeah I'm not I it's I'm still a little green to the app router and how it works but yeah basically the header and the footer are going to be loading in they're right here header and footer so here's the header which is the uis so here you can see we have the the home which is the root which is here we have the subgraph which is here that's here and then we have the uh debug contracts which is here so you can see here there's a bug an icon there's the bug here's the magnifying glass right here right so you can start adding to this

later the headers here and then same thing goes for the footer this has like the faucet the current eth price um eth is up all right um yeah so basically we're going to build out here okay does that make sense any questions so far good okay so you can see here we got some stuff that's great out here like we don't need these things we can take those away we don't need link we're not using that we can save it let's make sure it still loads Okay so I want to get into first is just the configuration right now we're still pointing at hard hat so inside of the root of SCA scaffold e nextjs folder

there is a scaffold doc config.rb betum if we start typing it picks up the types automatically because we're using typescript everyone remember that use typescripts so arbitrum saoa there we go so I can just click it it knows what type I want to do and I can hit save so it's under scaffold config Target networks now if I go over here you'll see I got wiped out I got knocked out on my my burner wallet that's because we

don't want to use a burner wallet anymore we're on a public test net we need to use uh something that's a little more secure this is where it's like okay we need to use metamask right we've secured our private key all that good stuff don't don't share your private key uh all that good stuff we could use rainbow we could use a hardware wallet whatever you choose we're going to use metamask because it's super easy and here we go now I'm logged in I have my ens name it shows me I'm connected to arbitrum sooa I have my 29 eth um and now I can start interacting with my smart contract so so I could say okay cool well here's my contract is that right this is 0 x173 here it is that's is that is that right yeah 0x1 173 so my contract's been

deployed if we actually look at scaffold eth and we go to the contracts here's the deployed contract there's the address for it oh wait that doesn't look like it matches actually um but that's okay um so it's it's working um now we can propose a transaction so now let's send vitalic another message but we have to connect the wall I already did up here yeah but you you'll need to so you'll have to like if you haven't connected it'll pop up like this you click that and then go to metamask okay yeah okay so let's send vitalic doeth a message say cool

cat all right hit send now it's going to be a little different experience we're on a public test net it's a little slower I have to actually approve the amount of gas that's going to be sent so it's going to cost me a dollar in arbitrum sapoia eth I can confirm that and I can send it now it's going to mine the transaction it was successful and now it's good so I can also update the greeting to uh I don't know like .e is the best in the west no that wouldn't make sense I can hit send boom now I want to touch base on one thing that I didn't really cover earlier uh I don't have enough eth yeah

I do okay I'm having some weird stuff with the network I don't know what's going on uh but that's okay it worked let's see if it worked okay herb a is the best so it worked it let me change it I don't know what that was about anyways I want to focus on one thing and I didn't really cover this but I think you may have done it with um Matas we've deployed this contract as this owner 0x17 wait is that right okay this is the owner yeah so this is the deployer contract so this is the contract tojust sorry so the contract here is here 063 that's why it didn't match earlier oh 062 okay so yeah so our contract one second our contract address

is here all right that matches here right the address owner though that's that's the outlier that's the pro that's the thing I want to talk to you about we are using the U the default deployment script of of of hard hat so if we go to hard hat and we go to uh deploy there's a deploy your contract script and one thing it's important to know is when we deploy our contract let me scroll down here when we deploy our contract cont we uh pass an argument with the deployer and we get the deployer right here so deployer equals await H.G getn named accounts so

it's going to take the very first hard hack account and use that to deploy our smart contract there's two ways that you can take control of the contract because we're deploying to a test net you should want to deploy take control of the contract there's actually three ways the first way is I could grab this private key and I could trans uh TV went off excuse me the TV went off um so there's there's a few ways that you can do this so the first thing is we can manually set I don't know maybe was I move something there's just too much power

being drawn from my computer uh I can set the uh argument here to wherever I want so if I wanted to I could pass my address here so I could copy my address and I could do it like this like that and I could just send my address over that's one way another way is I could uh write some kind of script that uses the transfer function to transfer the the um the owner I would probably say that you could just put in the address here that you want the owner to be that's the easiest way the other other option is we could um um I'm trying to think what's best practice

anyways there's lots of different ways I would probably just use this one it's easier so you can just paste your address in here um we're not going to mess with that right now because I've already deployed the contract so I kind of want to move in but that's just important for you guys to know that you'll need to do that okay so we're now our now our application is working we've been able to set the the GRE reading we didn't transfer the ownership we probably should have um one thing we could do actually that is probably a cool thing is we could actually redeploy the contract if we wanted to using ownable so has anyone heard heard of open Zeppelin before open Zeppelin okay so open Zeppelin kind of creates like

industry standard subgraphs and inside of our our smart contract I'm kind of jumping around a little bit but I just want to mention this is uh the ability to import open Zeppelin so it's kind of already here for you ownable doou now the thing about this smart contract that you get with scaffold e is it already kind of comes with an um Access Control pattern so you would need to kind of gut it a little bit uh and so that would involve you doing things like removing the uh Constructor address here um doing something like this removing that REM removing the modifier there's a lot of things you'll need to

do to get it kind of to the point where you can use ownable but I just want to mention that that I would recommend you do that because ownable is kind of like the industry standard way to do access control and there's also a a function in there called transfer that allows you to transfer the owner of the smart contract as well so the proper way would probably be to do that just for the sake of time I don't think we have time to really go too much into that but I would look up how to do that and it's really easy like I said you'll need to change your smart contract the chances are you're not going to use this smart contract you're going to start from scratch right so um let me just re re do this real quick not save okay so let's say we've we've

upgraded our front end a little bit here to point at we've been able to kind of update our greeting we've been debugging our contract we've been doing everything locally now we want to start building out our UI our user interface yeah oh sorry yeah I know you had a question sorry from how you change the network yes it's in the scaffold config yeah so it's inside of applications sorry uh packages nextjs and then it's the scaffold doc config.txt fromia

yeah okay so at this point I want to just start talking about the front end stuff so inside my my readme I kind of give you all the stuff you need um sorry it's this one here um the main things I want to talk about with scaffold e is scaffold E uses wag me which you can use basically wag me to get like the account that's connected and then we have all the the hooks and then we have all the components the of scaffold e so those are like components that we wrote that make it easy and we're going to go through right now and then there's some additional stuff in here in the readme that will teach you this stuff so those

will be your like best friend uh if if you're uh building on scaffold e which you have to um I did it again sorry um okay so we'll wait for it to load real quick it's here so just give it one more SEC sorry man I don't know I I heard they touched it but okay there it goes okay so I give you all the the configuration what it should look like um basically we're going to start out with kind of like this here so let's let's do

it one by one so we've kind of already kind of wiped out all the the center text here but what I want to show is here kind of what we're doing so let me just grab all this stuff so basically uh and we're going to paste it into this page TSX file why did that not work import type oh oh I have it duplicated that's why okay so we can put this one up here okay so basically you know with the vs code it's going to tell you what's being

used and what's not being used so obviously we're not using anything here but we have it all imported and there's no errors uh there is this little weird one but wagy always does that I don't know why um the first thing that I'll tell you about is this use clients so because we're using App router I think app router is kind of considered experimental it's not mainstream yet uh and more importantly it doesn't support uh by default the ability to do use States I don't know why but there's some kind of issue with it so you have to tell it specifically to use client so that that thing on the top is kind of like a Band-Aid um so more importantly if you

add sub pages and you're try to use State you might get an error and it's very hard to understand what the error means but you basically need to tell it use client if you're going to use any kind of state so react you know use a state and obviously nextjs is built on react so we're going to use uh state from react we're also going to use Apollo client let me make this a little bigger we're going to use Apollo client if we were going to use like the graph because it's graphql we're actually not going to use that we can just kind of get rid of that uh we're going to use use Query no we're not sorry let's get rid of that uh we're going to use wagm to get the address so we're going to import use

account from wagm which allows me to get the address we're going to import the components from scaffold eth there's a bunch of them but the ones that I'm going to show you today is address address input and balance so these are all like one is like a really cool way to display the address in a nice like pretty way one is a way to like import the address you know how earlier when I took type of italic eth and it converted it to his pfp and it showed me and it did the enss resolution that's what that is so it's automatically doing all that stuff for you which is really cool because that way you'd have to write all that in the code the other thing is the balance it will actually go out and query and get a balance for an address using balance we're also going to uh be

able to read from our contract and write to our contract by using these hooks so there's a balance uh one there's a a used deployed contract and then there's a use scaffold contract read and there's use scaffold contract right and I'm going to walk you guys through each one okay so the first one and again this is all in this documentation what we're going to do is you uh Define a um new div so in this case we're going to add a div like right below here if you um you might need to do some like formatting to make it pretty I have

an auto format I don't even know what I use um maybe it's prettier I think I use prettier um so here we have a div so div if anyone doesn't know it's basically like a a divider or like a group of any kind of like content you want to do and so in this case we're going to create a div which is a container basically with two things an address and then a balance and we need to Define where those addresses uh for each of those components is coming from and so you can see here we get this squiggly mark because we don't have the address so so how do we get that so we need to do that here so we can do

const that we have no it's not I have yeah I just haven't done it yet yeah so it gives you what we need here I was going to type it manually but here it is so here what we're doing is we're using wag me so wag me is here use account and the cool thing about um if you're using VSS code and you're using types is you can do something like this and you could say like uh what are we going to do const address I'm also using co-pilot which if you guys aren't using co-pilot man it's amazing you need to use it uh so equal and then we're going to do use

account now if I do use account it's going to automatically import it for me you see that it just popped in here um so that's really useful because it knows that that type exists and it's going to automatically import it from me in vs code but that's fine um we had it up there before but now it's down here [Music] um sorry this is not right so there we go so now I hit save and let's go to the front end oh there's an error there we go cool so I am getting the address from the connected wallet which is use account

and then I'm displaying the address here in this little pretty thing it has got a copy button which is cool because if you just want to copy that and then it also we have the balance right here as well which is passed along in the component as an address so there we go we're starting to kind of build out like a little basic UI by the way this UI is not going to be pretty I not a front-end developer I'm just showing you guys how to do it yeah the CSS of the of the things we are seeing areic or yeah so as far as this stuff goes this these class names that's a good that's a good question um these are all from Tailwind CSS so if you want to do anything with tail man you can uh but yeah that's what

we're using how you you haven't typ it man yeah I just copy paste this stuff in uh but it will Discover it because it is in like let's say you it PT I think PT Dash oh maybe it doesn't I thought it did oh control space ah there you go thank you see I'm not a friend guy CSS I just like goes way out of my yeah yeah okay anyway so you get the idea it's working um okay so now what else we got we could also we can go down so now

we've added an address and a balance component let's also add a the greeting the current greeting so here we'll add another div we'll put it right below uh here like this and we need to get this data so we want to display the greeting uh I already put the CSS there because I'm not going to do that in real time but we need to actually get the data so in this case we can do that using this function here so it's going to be um we can just grab it up here so what this is doing is it's being uh giving us the ability to grab the data as a greeting uh object using scaffold contract read so scaffold

contract read if I was to I think hit control or just hover my mouse it will tell me what I need to pass there so in this case uh it's telling me I need the contract name and the function name and it can also take arguments if there's arguments required right but in this case we just want to get the contract greeting so that's going to match exactly what's in our existing contract so here it is and it's called Uh uh what is it called uh your your contract so the contract is here your contract and then the function name is greeting so there's a getter function for the greeting and it's right here so the getter function for a read is greeting

so it's greeting so we're just passing in the contract name and the greeting so if we had multiple contracts you would need to specify if it was a certain contract in this case we only have one contract we're deploying and we have a function name called greeting so if we hit save now this error went away and now we can go back and look at that in the front there it is so now we have the herb. eth is the best that we're getting from there any questions Yeah so basically we're just doing so we have a separate div for the

address and the balance then we have this new div which is getting just the greeting in this like response variable syntax just like whatever like raw raw data and we are passing uh we're passing in the value of greeing as a data object here so we're getting it into a variable using this hook so use scaffold contract read is for reading information the contract name and the function name are both the required fields to be able to read the data okay okay so now let's uh let's pretend we want to we we queried the connected wallet now we want to query like um

another another component in this case we want to get the contract balance and the contract address so how do we do that so we have a new div here so let's put that right below this one and in this case we we need to Define where the contract is coming from so in this case we're trying to uh get the contract's address and the contract's balance so how do we do that well it's right here there's a hook for it so we can paste that in right below now what this one's going to do is it's going to same thing it's going to allow us to have some data that comes back uh in this case it's called your contract that we want to name it which is what what we need here right and then we're going to use deployed contract

info and pass the contract so just like we did before we can hover our Mouse here it tells us what we need in this case it tells us exactly what we need which is the contract name so in this case it's called your contract and then it shows us what the types are and all that good stuff um which is really useful everyone should use typescript that's that's why it's so easy and then we can save that and then come here again and now we get we have the current connected wallet on the top then we have the contract address and how much balance it has so if I was to come over here grab this address and then send some some e there uh let's go send let's paste the address and let's do

0.005 e hit next hit confirm come back over here there it goes now it has eth right I sent it some value so now it's pulling from the contract Okay cool so now we've got we've got this way to read uh from the contract read from the connected wallet read from a certain function so now let's say we want to uh do something a little more let's say we want to create an input field and change the greeting Okay so getting a little more technical here but for the most part I'll walk you guys through this we're going to add another div here and this one is going to have an input

field so we have an input field where the the value is going to be a variable called new greeting so it's the greeting I want to set it's going to have a placeholder which is just like empty space so type here it's just going to say that it's going to have a class name of input and then it's we're this is where we start to use uh State because as the user's typing in right on the in the input field we have to keep track of that somewhere so this is where we say okay well we can store that in state and then we have a button that uh basically will allow us to update the state so in this case on click we will set greeting and this is the name of the

button set greeting okay so to get that it's it's a little more complicated but it's right here I'll walk you guys through it is we can say okay so first of all I mentioned we need to use state so as the user typing in there whatever is in there we want to keep track of that in a state so we start the state as empty so as we start out with nothing nothing's in state then we set a new V new greeting uh and then a way to update the state based off the uh sorry a way to set the new greeing Bas based off the state basically to pass it so here we do a right async that allows us to set the

greeding and then we use the scaffold contract write function so earlier we just did a read to get the uh particular uh variable that we needed back now we're actually going to call a right function so this is a transaction so this is going to use I think it uses VM under under the hood to formul ate a transaction and actually submit the transaction so this is like a wrapper around VM so you don't need to know VM you could just write everything in VM if you wanted to it would support that but I recommend using these because they're already written for you and they're easy to understand so in this case we have a contract name called your contract it's the same right we have a

set greeting function right we have the greeting function here is to read this one is to write the only difference is that this one requires arguments because we actually need to pass the greeting so what is that greeting it is the new greeting that's in state so whatever is in state the minute that this hit gets hit uh on that button which is here on click set greeting so it's going to call the set greeting and whatever is in this state new greeting is going to be set so it passes it through yeah where's the what um the functions uh they're inside of

um components I well now I have to I have to look but let's see I think we can actually look here H oh yeah here's hooks yeah yeah control click right um I don't know why it's not working or maybe command click oh command click yeah so here it is yeah so there's a scaffold e folder here's the address balance yeah so if you want to see what they're doing under the hood you can kind of come in here and see yeah so hard hat VM yeah I I don't really I I have not

dived too much into this stuff I mean I kind of know it at a high level but anyways okay any other questions no okay so now we should have this new fancy button where we can set the greeting and a and an input field so we can say like hey her.e is here to stay I don't know set greeting now it's going to formulate transaction send off the transaction I just need to sign it and then we're good right so now it should have updated if I was a good developer I probably would have stored that thing in some kind of like uh a venture oh there

it go so there it goes it works okay so what else can we do um so now we can do a send message I'm actually going to skip that one because it's the exact same thing I just did you guys can do it if you want but it's going to allow you to do a read and a write so in this case we just have two things that we need to keep track of because we have a address input that is the who the message is going to we have a d another div that keeps the input field for what the mess message is going to be and then we have another button that allows us to send the message so it's using the same kind of like functions that are here which allow us to send a message right here but it's going to uh input it I'm going to skip

that one because I'd rather you guys start trying to do this stuff and then if you get stuck let me know and then this other one I also am going to skip because it's the graph but super useful is if you want to know how to read data from the graph this walks you through exactly what you need to do using gql and use Query and how to get the data into an object and there you go and this is where it tells you how to ship to a test net so here we say yarn run generate so these are all the commands I ran earlier yarn run generate yarn account is where you get your account this is how you do a deploy deploy this is how you do a verify if the verify doesn't work um there's a way to do it with the API

key and I'll try to give it to you guys and I'll message you guys in the chat don't be too worried because you got to provide your source code anyways to uh the urb E team uh but in general you should verify your contract for some reason arbitrum spolia just doesn't work out of the box if it was spolia or guery it would be no problem it would work okay so I want to give you guys a chance and I also want to uh see if you guys have any questions so why don't you guys try to go through and make some UI changes um it' be cool if you made them all but if you guys want to at least just give it a a whirl um and then if you get stuck let me know and then I'll close up just the last 50 so we'll do

this for like 10 minutes and then I just want to close up talking about our graph Advocates program and I want to talk about build Guild and how you guys can get involved okay any questions yeah um can you repeat how do you set your own private key in order to deploy with it yeah so you just run yarn run generate I mean private uh yeah you could I guess you could do it yeah I think yeah so I mean I could show you I let's just yeah so I think if you edit this EnV file with your private key then it should work so if you could it does work yeah yeah it should

work don't know if I had to it like we already said on the previous lesson structure okay yeah I'm going to check the uh chat folder right now to see if anyone needs arbitrum eth and I'll send you guys some so make sure you join that uh it's under here graph Builders office hours I'm sorry now here graph Builders herb eth and then here's an okay so I'll send some [Music]

here bet say that

again sorry oh yeah's the sorry what I can't hear it sorry man what your oh the my GitHub it's km Jones 1979 km Jones 1979 did you have a question no you're good no questions no you good red I don't know I don't know why

it's doing that yeah it works um yeah I'm not sure I the other day I noticed that and I haven't been able to figure it out so so it's it's okay like that okay all right anybody have questions where can we get what sorry I'm really hard to hear you what slideshow uh it's in the um the slides are inside doc as well so I think I linked him so yeah if you go to here the slides are up

here yeah if you can't access them let me know but it should work uh you had a question diagram yeah which one uh for the to the subgraph yeah it's in the slides yeah so if you go to the if you go here to uh this there slides are at the top right here okay was there you about the the diagrams I showed in my slides is that talking about oh yeah uh up up up up up up there you go uh is itone there did you try refreshing it yeah just oh here it is there it is there you

go yeah let me know if you can't access slides any other questions any other questions no cool uh couple more minutes and then I'll I'll go into the last kind of [Music] section excuse

me anybody stuck at all are having any issues no cool you guys are awesome you guys are really killing it you guys got through everything I I I applaud you guys [Music]

[Music] for [Music] I'm going to send off this e for you guys right now and then I'll I'll get started on the next part okay sorry every time

so cont it's gas [Music] yeah yeah so it's a good question I I will address that one second hold on [Music] what do you need to change oh like you do oh because of your steps oh talk to uh uh what's his name

he's the owner actually um okay so a good question that just someone just asked me that we didn't really talk about probably much in this um is gas right I think you guys like briefly touched on gas probably a little bit um yeah gas is kind of expensive in the terms of like you know when you make a state change on the blockchain you're actually like submitting that to all of the nodes on the network yeah if you guys can just bring it down just a little bit so you know you're you're basically paying for the security of the network right um so yes it's expensive there's lots of things going on to like

try to de de U lower that some of the things that they want to do is like sharding the blockchain to make it to where like maybe you don't need to like replicate that stuff across all the network um yeah there's some other stuff that like they're thinking about on like scaling wise like how they can make it cheaper um one of the things that did help is like uh the most recent uh I fet the EIP number but the thing that allows like burning which basically increases the the gas fee and burns e so it kind of incentivizes people to uh wait to to post do their transaction there's also layer twos which are a lot cheaper so a lot of people are kind of like saying okay well we should probably scale like

apps that are like more like frequent updates we require more transactions to a layer 2 Network like arbitrum which is a lot cheaper um but yeah I guess it does depend on what you're storing and the the size of the call um try to store stuff off chain if you can on like ipfs and R weave only you know change state for things that you really need to that would be my advice yeah okay I want to talk about a couple things first of all is the graph Advocates program so the graph Advocates actually funded for me to come here today uh it's part of the core part of the graphs Community um and essentially it's an

Advocates program that anyone can join who is like kind of passionate about the graph so if you guys were interested in getting involved in like web 3 it's kind of a good way it's a pretty good community of people from all over the world um Paulo who is like the community manager for the graph Foundation is here in Rome he was here a couple days ago I don't know if you guys saw him um I think he'll be here tomorrow really cool guy he's a great resource if you actually really want to get invited into the community and like kind of learn um if I if you guys could bring down the volume just a little bit there's different things you can do you can be uh an event evangelist so you can actually like host events kind of like what we're doing today um you can do

online stuff if you want to uh grow more broader Community you can also be just a content creator so if you want to write blogs you want to do workshops you want to create videos like if you're passionate about one specific thing a podcast whatever there's different ways that you can get involved by doing creating content if you want to translate documents that are you know maybe developer documents or docs or social media posts that are in another language if you're bilingual you can get involved there uh you can also do thing what's called Community Care so you can just kind of like help out with like the community being active in telegram Discord uh The Forum stuff like that or you can be like something like a technical teacher like also like me where we're actually like getting into

the nitty-gritty and like teaching people um and and teaching people how to use the technology okay any questions about that yeah it's about the graph in general it could be used like to let's say we have a web game like Tove charts statistics regarding the like this yeah I mean technically you could store so you can index anything that is on chain that's a supported chain or anything that's in ipfs or R weave so like static files um images there's been some like experiments where you maybe you could like put some images and some HTML and CSS definitely could do it with like SVG

because you know you could like render the stuff uh yeah it's a cool idea [Music] actually ipfs I the first thing I think about is the U of an NF M yeah that includes ANS I would like make statistics that in trades using the the yeah you could do that yeah there's a lot of nfts like if you look at the Crypt punks example that's a good one to look at because it references all the traits that are on ipfs and ingest those um I believe uh so there's a crypt punks um if you go to the gra.com Explorer and search Crypt punks there's

one on arbitrum that was written by Jerry Jerry o Colo I think his name is he works for the graph actually he works for edge of node and uh that one I think does that it does um uh data it does data lookups for all the traits and it also indexes the event contracts and it it has a lot of stuff in there where you can do it yeah a lot stuff regarding how the crypto Banks pass from wallet to wallet yep Yeah so basically like the graph we we talked a lot about the graph today the graph is you know for indexing decentralized data or sorry uh ipfs R weave and events from ethereum there's also some other cool stuff like you can index all the data from the blocks as

well using what's called um uh light sorry toilet blinking right now it's called Uh substreams I don't know what's wrong with me today fire hose to substreams which allows you to like parse like really detailed detailed information that are in the ordinals of a block so there's actually a lot of flexibility on the data you could get um uh from fire fire hose as well fire hose and substreams for example getting the the old list M by number of something is not so easy on the sh yeah or you have a service that allows you or else you can meet yourself with the graph yeah I just want to show real

quick for graph Advocates if you guys are interested all you need to do is go to graph advocates.com and apply here and you fill out this form and someone will contact you to set up like a interview and then kind of like how you want to get involved in the community you don't need to be an expert on the graph to do some of the jobs um and if you even if you're a new I would recommend it the other thing I want to talk about is um build Guild okay so if if you get to this haathon which you all are um I want to see you guys submit uh after you're done this should be where you go speedrun aum.com who's here has heard of this okay speedrun ethereum is the best way to kind of like test your skills

this is built by Austin Griffith and this and the scaffold eth team so it's all built around scaffold eth so you use scaffold eth to basically go through these challenges and you kind of like test your skill the first one is you deploy like an nft it's really easy the second one you go through and you deploy a staking app so you learn about how to like stake your tokens and how to get back you know something then you also bu build a token vendor which allows you to like basically create an erc20 essentially then you join the build Guild so this is the what I wanted to mention so once you Jo can't join the build Guild that's funny I am in the build Guild um the build Guild is like a a cool concept that's like blows my mind

to think how much the build Guild is actually involved in the ecosystem basically it's decentralized developers that are actively building on ethereum and there are people that are building these different uh challenges Building Products there's a core developers that work on scaffold 2 there's people like me that do evangelism um but it's all built around the concept of scaffold e to and there's a lot of cool uh projects that have spawned out of this one is like ABI ninja address. vision is really cool you can click here to see all the projects that were built on scaffold eth if you guys are looking for some ideas but this is the cool part 703 eth has been streamed to develop velers uh for doing

active stuff in the community so it's a Ubi kind of uh model where like if you're a developer you go through you join the build Guild you show your work and you show how good you are at building on ethereum or building daps you can actually get invited to the build Guild and get a stream if you're good enough and we can incentivize You by paying you a stream to do things in the ecosystem okay so there's over a thousand build uh Builders I think it's more actually there's about 30 or 40 that are like kind of core Builders and then there's over a thousand different builds of scaffold e that have been submitted uh as like kind of like examples or use cases so there's lots of ways that you can like kind of get a real Tap on what's going on with

developers uh like you know integration with something or a use case of of like something new that's coming out like account direction or whatever it is that you're passionate about um and then once you join yeah you can basically be in the build Guild and you get upgraded and you have your own little profile um if you go here to uh here you can see all the different Builders how much eth that they're streamed uh everything's public available these are all smart contracts by the way so all these smart contracts are available so I highly recommend you guys check that out all you need to do is go to speedr aum.com and join that do you have your own uh yeah it's like a punk wallet kind of concept we yeah we just generate like

a punk based off the address oh yeah okay so it's not a punk it's not a crypto Punk it's a yeah it's a build Guild Punk uh yeah so if you see like I have one I don't even know what mine is mine's weird it's pink ha on on the public key uh yeah it's based off the public key yeah there's also Punk wallet which is really cool so like I was showing you earlier is like Punk wallet you can load on your phone and it's got like a QR code scanner and you can like scan the QRS and have it's it's a browser based wallet it's not super secure so I wouldn't use it like for main funds but it's good for like developer testing and

stuff like that um and there's some other apps like we actually built another wallet there's a scaffold e wallet too so there's a lot of cool stuff um with scaffold E I go yeah you got to join you got to join okay so we we did a lot today um we went through the full stack dab stuff um talk to you guys about speedrun ethereum um I sent you guys some eth uh I'll be around to help out I think tomorrow we're going to do team formation stuff and and what else what else we going to do tomorrow some thinking yeah so tomorrow is going to be good because we're going

to talk to you more about like you know how you can really like build something cool um yeah excited to help you guys out uh does anyone have any more questions that I can answer about the graph or scaffold eth or even just questions about uh hackathons I go to a lot of hackathons so happy toath guideline or do whatever I want um I think the main rules are I mean he talked about earlier is like you need to use scaffold e you need to deploy to arbitrum Saia um you know it should be obviously a smart contract that you make changes to a decentralized application nothing too specific no I don't think there's no rules for what kind of yeah

products it's not like you have to build this kind of an app um just as long as it's a smart contract it's deployed to arbitrum use scaffold you know yeah cool any other questions you guys have no yeah so the last thing I'll say is like um everything you really need to like kind of get going and up and running should be in here you can literally watch this video and like replay if you get stuck on anywhere with the the stuff there's tons of videos on scaffold eth a lot of them are me or Austin Griffith so if you get stuck just let you know look on there uh we also have um a telegram channel for just dedicated to scaffold eth so if you I

think it's in here on the bottom let's see I'll I'll post theuh URL so it's um or maybe it's on here let's see support let's see yeah there it is so if you go to scaffold eat.io go all the way to the bottom and there's this support button right here that will open up the telegram chat if for some reason I'm not available because I don't know I'm asleep because I'm jetlagged you might be able to get help in here there's like 2,000 developers in here so if you guys get stuck with scaffold e come in here here post your question um and yeah I'll also try to invite uh a couple devs into

this herb boot camp thing as well to see if you guys have questions there you can ask as well but I really just set this up so if you guys have questions about the graph in the future so cool thank you guys so much you guys are all awesome thank you thank [Music] you

Related talks