# Building a Basic Smart Contract with Scaffold-ETH by Kevin Jones | Devcon SEA

- Speakers: Kevin Jones
- Channel: [Devcon](https://streameth.org/devcon)
- Date: 2025-10-07
- Duration: 1:20:26
- Watch: https://streameth.org/watch/yt-u-kIPcapQ2E
- YouTube: https://www.youtube.com/watch?v=u-kIPcapQ2E

## Description

In this session, Kevin will help you create a basic smart contract using Scaffold-ETHv2. It's a hands-on way to learn the basics of writing and deploying contracts on Ethereum.

Speaker(s): Kevin Jones
Skill level: Beginner
Track: Developer Experience
Keywords: Developer Infrastructure, Tooling, react

Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum, https://warpcast.com/devcon
Learn more about devcon: https://www.devcon.org/
Learn more about ethereum: https://ethereum.org/ 

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on Swarm, IPFS and more.

Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. 
Devcon SEA was held in Bangkok, Thailand on Nov 12 - Nov 15, 2024.
Devcon is organized and presented by the Ethereum Foundation. To find out more, please visit https://ethereum.foundation/

## Transcript

[Music] help yeah all right cool can you guys hear me good awesome good morning everybody I hope you guys are having a great time at Devcon uh I don't know about you guys but this just has been a great week I've seen such cool talks and the the build Guild is here and full uh representation and we're here to support you on scaffold eth and building on ethereum so we're going to be focusing today um on scaffold eth we're going to explain a little bit about scaffold eth um just to kind of feel for the room who here has actually used scaffold eth before anybody or is it kind of new okay cool couple hands who here is the software developer who here is an aspiring software developer okay so we got some new people we got some people that probably have some experienced coding um so I'm going to try to keep this kind of a slow pace a lot of the workshops uh that we had here this week have been a little bit quick hard to follow so I do want to make it kind of uh paced at a at a a pace where you guys can follow along especially you know being new uh in building on ethereum can be a little uh daunting uh who here attended another scaffold eth Workshop this week anybody few okay we had a lot so um who here's hacking at the hackathon a few of you okay cool thank you for the hands I know you guys are probably like but um Okay cool so I appreciate you guys time uh my quick intro about myself uh my name is Kevin Jones I work as a de developer relations engineer for the graph protocol uh but I also am a core member of the build Guild supporting scaffold eth onboarding and education in ethereum um and it's actually how I got my start into ethereum so uh it's very appropriate I continue to be very active in the community um scaffold eth is a tool that has come out of the build Guild or the Biddle GID uh the Biddle GID just real quickly is a basically a dow uh that is uh basically focused on education and tools for the ethereum ecosystem uh so if anyone wants to get involved with with the build Guild you can totally do that and I highly recommend that especially if you're uh getting into software development and the ethereum ecosystem uh you can go to the build Guild app uh but really the uh the the meat and potatoes for getting into the build Guild is through a tool called speedrun ethereum so speedrun ethereum is this kind of U it's like a challenge kind of gamification on writing and developing smart contracts on ethereum and so you go through this kind of process where you go through and build different projects so you start by building a very simple nft you eventually learn to build a staking application and understand the concepts of staking taking on a a smart contract then you build a token vendor and then you do a dice game and you learn about Randomness on the ethereum blockchain uh and then eventually you get a little bit more difficult and you can build a DEX uh once you finish that you actually become a member of the build Guild so anyone can do that so highly recommend after today go to speedrun ethereum.org and test your skills right uh because it's a great learning experience too because you really have to think about you know what smart contracts are and how they work uh at any point today if you have questions uh in the app there's a questions and answer um I'm going to try to keep an eye on it when I'm here so I can see but also feel free to raise your hand okay I want this to be interactive I don't want you guys to to you know I don't want to lose anybody if you have a question about something please uh let's let's get it addressed okay uh so we're going to talk about scaffold e we're actually going to use it we're going to we're going to walk through how you use it and the idea is by the end of today we're just going to deploy a smart contract probably to a test net maybe like Bas I don't know we'll see um but if you want to get started on scaffold e everyone should go to scaffold eat.io okay there's two ways you can install scaffold eth you can clone the repository and install the dependencies using the uh git repo or you can use the npx script uh method the package the create eth package it's the easiest it says beta here I've been trying to get that to to go away but um we need to remove that it's fully functional and it's really probably how you should install it uh especially if you want to use Foundry if you use the git clone method it comes with hard hat if you want to use Foundry uh you want to use this method so all you need to do um but let's just look at the GitHub repo real quick um the the main benefits to scaffold eth and I'm going to show it off but is that it is kind of like complete with everything you need to like build a daap really it's great for hackathons it's great for prototyping it's great for like local First Development so you can like build locally and you don't have to like you know deploy to a test net you can use just the local chain and the local um front end that you have and it's just got all the stuff working for you uh it runs with some requirements so you need no js on your machine uh you need a yarn package manager and you need git so just one little bu bullet on yarn is make sure you have the newest version of yarn uh make sure you install that because if you have an old version of yarn you might have some issues uh and if you have s with node versions just try 18 or 20 those are kind of the most um uh compatible versions if you're running Windows I would use WSL so the Linux um installation for Buu and uh because it's going to make a lot easier uh I don't think it's really easy to use uh just like native Windows uh okay so let's get started so let's do exactly that let's go to npx create eth at latest right so if you have a a a terminal open it up uh go ahead and type that in so this is going to ask you if once you first do that it's going to ask you if you want to install that package so that will just take you know a little bit of time uh to install that um and then it wants to know what you want to name your package can you guys see that okay yeah anyone have make it a little bigger okay so we're going to name this one uh Devcon app sure uh it's gonna it's gonna ask you what kind of chain you want to use so we support both hard hat and Foundry um personally if you're new I would recommend hard hat uh if you're more familiar with typescript or JavaScript I would use hard hat if you're more like into this the solidity aspects of of uh ethereum and blockchains and stuff like that then Foundry might be a better option Foundry is a little faster you can write your smart contrast tests and your deployment scripts in solidity so it's a little bit less of a learning curve if you don't know typescript but personally I think hard hat is been around a little bit longer so I use that you can also do no chain uh if you wanted to just uh just use it as a front end a lot of people do that for different reasons but so it's going to go through and install the packages okay so this takes uh a little bit of time depending on your internet connection uh and uh your machine so we'll just let that sit for a second uh another thing about scaffold eth is again I mentioned it's a local first right kind of uh tool so you're running a chain on your machine and you're running a front end on your machine and then you're using another kind of terminal to do deploys so you need a few windows open okay so you can just open multiple terminals that's fine uh what I I use as a tool called t-o which lets me kind of split my screen up so I can do uh like this and I can split my screen into kind of a few different ways and then I can go into this Devcon app folder and these other folders uh but you can just do this in like three windows so just open a new terminal go into the same directory on each window so it's still installing the packages so we'll give it one second um let's go just really quick and go back to scaffold e. the next thing you're going to want to always do if you're just getting started on scaffold e is take a look at the docs the docs are super good super simple but they have exactly what you need to know um if you go to the quick start section it gives you the how to install all the requirements it tells you how to set up your environment so it talks about where the how you bring up your blockchain and we're going to go through this where your configuration for hard hat and Foundry is how to do a deploy um and then the components section is super awesome because this is these are packages that come with scaffold eth that give you some really cool added like added functionality out of the box that you don't so especially if you're not a front-end developer it's very difficult when you first like start writing smart contracts and it hooking that stuff up to your uh smart contract so an example would be like if you want to get an address and you want to get the balance of the address or just do like ens resolution there's a component for that so you can use that we're not going to be focusing a lot on the front end stuff but tomorrow Eda is doing a workshop and if you are struggling with that aspect I highly recommend you do that because she's going to uh focus on some of the front-end stuff uh we're going to pretty much just do smart contract stuff today uh you there's also a balance component uh which is cool so you can see what the balance of an address is there's an address input that you can type in an ens and it will resolve it to an address for you a lot of cool stuff uh ether input so it'll figure out what the dollar amounts are at the current time uh based on the uh input and then the last part I just want to show real quick before we get started is the uh interacting with your smart contract so there's also hooks in scaffold eth for reading from your smart contract or writing so if you want to read some data from a contract in a specific function you can do that you can pass in arguments if you want to write a transaction to the blockchain from your front end there's a re a write function for that and that is also available in here so like this is an example of a button that will basically call a function called greeting set greeting with a value passed as an argument and maybe value as like a transaction like maybe you want to C like pay pay in some value in the transaction and then does some error checking and it's just a it's a really nice component really easy to do okay so again this is not a front end course but I just want to mention that if you're first getting started that's a great place to go okay is it done yes okay cool bought myself some time all right so we're going to we have the package now set up it's kind of ready to go so we're going to go into our uh Devon folder in this one and we're going to run yarn chain so all this does is scaffold eth is a mono repo so what that means is it has like multiple packages in one and it has this package Json file that has a bunch of scripts that you can kind of just type really easily using the yarn command so yarn chain runs whatever local chain you want to use so in this case we chose hard hat um so what it does is it spins up the blockchain on the local machine Local Host and then it gives you these private keys and public keys that you can test with right uh and then so if you wanted to you could inject those into like your metamask if you wanted to or something um but we're just going to use something else which is really cool about scaffold dates that I'll show in a second and then this other window we're going to open up our front end so you always have your chain open and then you always have your front end open okay I'm having a bad typing day today okay warm up my fingers all right so we now have our chain running and we also have react running so scaffold e also comes with react with nextjs and it is the app router implementation of that um I'll show it off in a little bit here but it's up and running it's ready to go it's on Port 3000 um let's go ahead and just open up scaffold e over here on Port 3000 everyone following along yeah cool anyone anyone having yarn errors hopefully you're not few okay so just make sure you're using the newest version of yarn uh and also um yeah trying to think what else that's pretty much the main thing make sure you using a new version yarn and if you have to change the version of node as well sometimes there's like issues with different versions of node you can use NVM which is node version manager to swap node versions 100% recommend that too okay so scaffold e is up right we have it up and running um if we firstly scaffold eth here it's very basic but it gives us this uh our connected address it's kind of like a hello world page it tells us how to get started editing our our application it also tells us where our smart contract is that comes with scaffold e uh but it's also what's what's the really cool thing is this debug contracts tab so right up here it's debug contract stab this is kind of the magic sauce of scaffold eath because one of the hardest parts uh of of understanding um you know writing a smart contract and then interacted with your front end is every time you create a smart contract and you compile it down into bite code it also generates an ABI okay so the ABI is this kind of like treasure map or like uh how you actually can navigate all the functions and the variables in your smart contract now what scaffold e does is when we deploy our contract so we come down here and we do yarn deploy and come back it's going to give us some output here it's going to say okay cool the contract was deployed successfully this is how much gas it took this is some output that we get from our deployment script and then we see some terminal output here with console log so we see what's going on and we see that our front end also refreshed so if we go back there we get everything that's in our smart contract inside of the front end okay so that's really powerful because you don't need to go in there and write uh you know frontend code it's just ready to test so we can kind of look at this and know exactly what our smart contract looks like it's got some greeting function or greeting uh variable it's got an owner variable which is an address it's got a premium which is a Boolean and it's got a counter which is an unsigned integer and it's got a read function and it's got two write functions right so it's got this greeting that I could change the greeting so I could say hello world or something like that or actually let's do hello Devcon okay like this and if I try to hit send it's going to tell me I don't have any gas so the next thing you'll learn about scaffold eth is you get this burner wallet as well so you don't need to connect to metamask you can just start transacting there's a faucet button you grab some f some funds from hard hat or Foundry then you can go ahead and interact with your smart contract so I just paid some gas I got a transaction receipt which has all the details of the transaction and I updated the state of the greeting variable so very simple so um if we go into our uh application and we look at that we can see that's exactly what our smart contract does so let's do that so here it is I use vs code zoom in a little bit so again scaff us is the monor repo so we have this hard hat folder okay and inside there we have this contracts folder and then we have the year contract so this is a very basic contract it has the hard hat console so this gives us our console logging output that we see on the left terminal that I have we have a basic contract called your contract it has a a owner address variable it has the string right here so if I come in here and say building cool apps save that redeploy and then I come back to scaffold eth we will see that my uh greeting will change here in just a second there it goes so now it's reflected my changes so the a lot of the the life cycle of of using scaffold eth is that you just come in here make a change to your smart contract deploy your contract change and then test your your you know changes right it's it's a way for you to like test your assumptions as Austin griffus likes to say so um Okay cool so we have this very basic contract it has a boole on it has a counter it has a mapping which is cool so it keeps track of like how many greedy meetings a particular address has done we'll use that when we build our smart contract um and then we have like some events which events are like logs on ethereum um who here would say they're new to using writing solidity few newbies so uh when you're writing solidity uh everything is very simple uh if you've written any other program language uh it's very simple to get started on solidity if you don't already know about solidity by example it is the most probably important uh website you'll probably uh be using over the next year it's going to have every single example of every single functionality inside of solidity and I highly recommend that you guys come here and kind of start using solidity by example to test um different functionality so there's like a hello world there's a first application which does like a counter and it allows you to like see how you increment the counter and uh this is just a great resource so if you're coming in here we we kind of have this kind of basic contract that's a hello world contract it has this event which is like logging it has a Constructor The Constructor is basically like at the time of deployment you might want to set some values so in this case we set an owner at the time of the deployment so we pass this into the deployment script which we'll go soon and show off there's a modifier so what I want to do actually is I just want to kind of like gut out this contract I want to show you that you can kind of just start from scratch and uh go from there so you should come into this contract and you should let's just get rid of some stuff so it's easy to see I still want to use hard ha hat console right so I'm going to keep that I want to get rid of all of these variables I also want to get rid of this I want to get rid of this event I need a Constructor but I want to get rid of the stuff that I'm passing in the Constructor and I don't want this modifier anymore I don't want this function anymore I want this function because this is an important one uh this is uh there's two important functions here that I want to keep one is a withdraw function did I break something here oh yeah okay uh there's this one function that is a withdraw function which allows me to withdraw all the funds from the contract and then there's another one that allows the contract to receive eth uh even though there's no receive function so it gives you that ability uh we also took away the modifier which we'll get rid of that we also don't have this owner variable anymore because we deleted that so we actually want to use message. sender so let me kind of show you what I did okay so what I did is I just took everything out I I kept the Constructor I kept the name of the contract uh which is the we want to use this year contract because we have also have a deploy script that's down here but I'll get to that um and we just emptied out the Constructor so there's nothing being passed at the time that it actually gets deployed but we keep this because we want be people to be able to come in here and withdraw the funds from the contract especially if it's main net uh this might get some some funds and we don't want them locked in the contract forever so what this does is it allows people to uh a user to make a withdraw function or call and anyone who does that who is the sender can do a DOT call and get the value which is the balance of the contract so we can basically rug pull this contract uh and then we can basically pass a success okay or require which um in solidity a require statement is something has has to happen otherwise the transaction will be reverted uh and then this last one like I said is just so that if someone tries to send eth to this uh address we still want it to be able to receive eth um so it just allows that that that receiving so it's like a payable function okay uh so yeah so we basically wiped it out let's save that and let's try to deploy so if you guys do that uh you're going to get an error you're going to get a couple errors actually uh so we could look at the errors in real time let's do it so this one's saying well I expected zero arguments but I actually got one argument when I was doing the deploy so if we go into that deploy script right below so again we're using hard hat in this version uh we are using um typescript to deploy the contract uh let me get rid of some of these comments so you guys can see what's going on but what we're doing is we are getting all well we're getting the list of hard hat accounts that are available to us by doing this calling got dogit named accounts and we take the very first one and we use that to deploy the contract so we use that private key the hard hat private key um and then we we call the dot deployments to do that to do the deploy and then we create a deployment right here by using the await so an await is like hey you need to wait until everything is done before you continue in this in this uh code and we deploy the contract now we say who the transaction is from right who sent the transaction uh and what were the arguments in that need to happen in that transaction so this is where the Constructor arguments are so as you mention as we mentioned earlier we took away the The Constructor arguments so we also need to take away the arguments here okay and we also have logging enabled and we have like Auto mind true you can take those off if you wanted to we'll just keep those there and then if we save that and then now try to deploy we'll get a new error but this is what you do in software development right you work through errors so then you're going to see well we got a type error in our deployment inside of our deploy contract we got this your contract. greeting is not a function so let's go back so another thing you'll notice is we do we get an instance of the contract right below here so we say okay if you have deployed your contract successfully take that and get a contract by using get Contract from hard hat ethers so hard hat ethers is an ethers implementation for hard hat that allows you to query the blockchain basically to get get the inst get the instance and we query it by calling the name which is here and we query it by calling the owner or who who it's from is the deployer and then we once we have that contract we can call any functions inside of it which is really cool so we can actually do some transactions here inside of the deploy script or we can yeah so in this case what we're doing is we're doing a console log and we're logging your contract. greeting but this doesn't exist anymore because I deleted it right so we also need to get rid of this okay so if we save that and then deploy again we should be in the in the in the good there we go cool successful okay let me Zoom back in no more errors so hopefully you guys have been able to get to that point so you should come in here you should Wipe Out the contract you you don't really need this withdraw function you could get rid of it too you could get rid of this if you want we're going to we just want to start from scratch so um what I want to do now and then you need to come in here make sure you remove the arguments from the args make sure you remove this console log that you were doing here and right below that and then you'll be kind of where I where I am um I want to pause a second for questions because I know there probably some people might have questions so let's just give like couple minutes to um answer questions uh put your hand up if you have a question and I'll check the app real quick any questions no yep F uh I was more focused on following up with the code I didn't really um get why did we do these changes I'm going to build out a new smart contract right now we're going to create an erc20 from scratch so I we want to it's kind of just when you're first using scaffold e it comes with this stuff to test and see how it looks but you probably want to just start from scratch so I wanted to show you guys how if you're doing a hackathon you can get rid of all the stuff you need and just kind of start at a base a new base and why these specifically like why why the argument and the the other line below I'll show you but uh that's a good question uh so the question was basically yeah like why are we removing the arguments well this contract comes with a um uh what's called an ownable pattern or like an ownership pattern where that owner address is kind of like the access control for withdrawing funds from the contract uh we're actually going to use open Zeppelin to do that and so I'm going to show you why in a little bit okay uh there was a couple questions in here let me just read them real quick so can you share the main difference between scaffold e Hooks and wagm uh we use wagm for some stuff like getting the account um but the hooks U they're just kind of custom and they were kind of imported from the previous implementation of scaffold eth um so they're kind of Rewritten to be more optimized I think they're just they just are designed for scaffold eth so that's kind of why they're that's how they're different uh can you navigate a conflict that's a silly question uh what vs code extension do you recommend uh definitely the solidity and and typescript uh highlight syntaxing um I actually recommend cursor I don't know if here's everyone used cursor yet if you're not using cursor at least like a couple days of the week try it out and you will really really really start to uh develop a little quicker okay those are good questions any more questions in the room yeah over here but I'm getting a address and use problem oh I'm getting an address and use problem for when I run yarn chain after running it before and closing it out that's interesting uh it sounds to me like it's still running somewhere so maybe you have it in another terminal that you didn't notice double check uh maybe just do like a PS and see if you can find the uh binary are you're running a Mac yeah I can't or it's Windows Windows Linux Linux yeah just do a PS like aox like um like this grab I don't know what is it uh Foundry oh you were using Foundry right something like that and see if you can find the process ID and then try to kill so do like a kill dash9 process ID I'm teaching you guys Linux too uh okay cool yeah try to just kill the process that should get rid of it okay let's keep going um I think we answered a couple questions if you have a question ask it in the app and the next time I stop we'll we'll go okay so we have our chain running we have our front end running let's start writing a contract we've wiped out the contract to at least Le a very base kind of spot the name of this Workshop is about smart contracts so let's try to write one just let's hope I don't mess it up but let's see okay so what I want to do is I want to create an erc20 but I want first I want to start by having access of this contract in a way that is probably the standard okay so we were using this kind of like um we don't want to use open Zeppelin we want to use uh ownable let's see if that works actually let me grab it from here because I forgot what it is there it is okay so we're going to use uh ownable now the the beginning contract scav comes with this kind of Access Control pattern where you have an owner of a contract and only that owner can do certain things right but uh the the standard way to do it the easiest way to do it is just to use open Zeppelin ownable so we're going to do that we're going to import ownable which is an access control contract uh that allows me to just take everything that's in this contract and import it by doing your contract is ownable like this and what that's going to do is it's going to allow me to deploy at the time of my deployment um okay so it wants it want so it wants something passed in the Constructor uh which I think let's see if we can do that I forget how we need to do it no arguments passed so I think it wants the owner passed here so we can set the owner so what I want to do is I want to use my contract address from the contract burner wallet that I have so inside my burner wallet so now that I've done my deployment the the script or the sorry the smart contract is pretty much empty I want to use this address here in the burner wallet as my owner okay so I'm going to copy that and I'm going to pass that into the arguments which I think is what I need to do let's see what is this that should work now let's try to do the deploy let's see oh uh address Constructor address initialize owner yeah that should be it oh I need to call so uh what's interesting I think I need to do your contract deploy and is it ownable frick I'm trying to think what I need to do it's in the Constructor oh yeah yeah yeah you're right thank you very much so it's not here actually it is here like this right ah thank you so we do so like this oh I got you okay so owner like like this I would say that can I do it like that I would say that yeah but you can take the arguments from the deployment if you want no it's fine okay well all right that's okay let's actually not do the ownable stuff let's just focus on the actual smart contract for the um erc20 I don't want to like hold this up um let me just redeploy this changes real quick okay so the basic functionality of a um uh token is that you have like a name for the token you have a symbol for the token you have a total supply of how much to tokens that you want to have uh and then you want to like mint that uh token to a particular address and then you might want to like sell that token on a exchange or something like that so let's try to actually do that let's just try to make a token so what we'll do is we'll do a um string public name and we'll call it I don't know everyone's talking about these frogs so I'll do frogs how many frogs do you guys have uh okay and then we'll also do string public uh symbol equal frog sure uh and then we can also do a total Supply uh let's do yeah 1 1 2 3 1 2 3 1 million times 10 the 18th power so uh in solidity um or I should say on ethereum you uh have this concept of decimals right um sorry spelled this wrong what am I doing wrong here oh thank you gosh like failing today okay so um you have this concept of um uh basically decimals so if we want to have 1 million tokens uh but we also want to have the um you know the full amount of decibels available we want to multiply this by 10 to the 18th power so we want to set the total Supply to 1 million uh tokens um and then that way it can be converted down so we have this kind of like total Supply um and so we can save that and then do our deploy and kind of show what that looks like so we do the deploy and then when we come here we can see that we have the variables are showing up we have the name we have the decimals we have the total Supply and then we have this cool functionality here where we can like convert sorry it's a little hard to hard to see but scaffold e can convert it from you know the standard ether values all the way down to what it would be uh in 10 the 18th power uh and so we can can see what the total amount of way is that that this token is worth uh but we don't have any way to um well first of all we haven't minted that we have the supply but we haven't actually transferred the the value of that and so uh the way that we do that with um uh ether or solidity is we create a yeah mapping so we say we want to keep track of the balances of any address that interacts with the smart contract and has some kind of like like balance transfer balance so we use what's called mapping so mapping takes one variable and essentially Maps it to another variable and so in this case we want to take in an address so any particular address that has a balance and we want to exactly tell how much that balance is and we want this to be publicly available so that a user could query what their balance is and when you do this with um uh solidity you get a git function so you can actually see what this balance is uh so if we query that uh so let me just save that and then in here we can set the balance of a particular address at the time that the contract deploys to anyone we want so we don't want to actually send it to message. Sender I want to send it to my burner wallet so it's here so I'm going to come in here copy the address and then I'm just going to paste that in here cool so let's hit send there we go so now we can deploy our contract cool so their contract is deployed um and we can see that how much gas it took and then if we go to scaffold eth now now we should see that we have this new read function right so we can grab this balance of this address paste it in here and do a read so you can see how you just paste in the uh thing it gives you this like little blocky dude and then you can uh do a read so the this is how much actually uh tokens that we have we can convert it by um you know seeing exactly what that is in eth uh and then we can go back and forth but we now we don't have any way to actually like transfer the tokens around so we probably want a way to trans transer that's the next thing that comes in um a standard uh token so then what we can do is write a new function so we will do a function oh gotta love AI it just kind of does everything for you uh so what this is saying that is we need to write a function that transfers by taking in a two address and an amount that we want to transfer this should be publicly available and then at the time that someone calls this function you want to do a check basically to make sure that they have enough tokens to send to another user because otherwise they'd be double spending right so we just do a little like a require statement and then after that we just update the balances so we say okay well the balance of the person who is calling the function so in in in solidity you have these kind of like Global variables which message. sender is the person that is uh sending the transaction so that's the the the the uh user what their public key basically and if someone's calling the transfer function we want to remove the amount that they're going to send and then we want to in whoever they're actually sending it to we update that mapping too uh with the amount so here we subtract here we increase okay so now we can hit save and we can do deploy cool so now we can go back to scaffold eth and we can see that we have this contract and you'll notice that every time we do a deploy we can force to deploy by doing a uh yarn deploy D- reset and you'll see the contract address up here in the top it will change and you'll constantly get a new contract uh and so that's why we're kind of like starting over from scratch every time uh because the nons is changing on the uh uh uh deployment so now we have this contract we have a very basic erc20 uh it's called frog it's uh the name is frogs it's got a total Supply I have a balance of whatever 1 million tokens right here so if I want to transfer some tokens now I can say let's transfer to vitalic doeth and let's send him some frog tokens sure uh 777 now um again we need to transact in way so scaffold e has this really cool tool that you just click the little button and it will multiply whatever values in the input by 10 to the 18th power so I click that and that will tell me exactly how much we that I need to call in the transaction and then I can go ahead and hit send and as you can see it did this nice ens resolution and we can see vitalik's photo um I'm really sad vitalic changed his little rainbow cat because that was a really cool one but now it's his face uh so there we go we have send and then here's the receipt so we know that it was successful uh and now we can come up here and query against falic address so vital. eth and do a read it resolved and then now we can see that he has a balance of 777 tokens so we've created this kind of like very basic uh implementation of a um of a erc20 uh so I want to show you how to do the other method so let's let's actually do uh let's take a look at open zeppin uh let see open zeppin erc20 let's see if I can find it here so you probably don't want to reinvent the will again like we were going to try to use the uh uh okay this is going to tell me how I can fix the ownable thing as well uh we want to uh probably just go ahead and use open Zeppelin right so you probably want to reserve the time that you're uh working on your smart contract uh to do something new and Innovative since erc20 is a very very good standard we can just use open Zeppelins okay so we can grab this here and we can come back here and let's just kind of like take away all this stuff we did and show much how much easier it's going to be if we just use open Zeppelin so we'll do this and we'll go here so we can say you're your contract is erc20 and then what we need to do is we need to pass uh the stuff inside of the Constructor so this is what I was not able to figure out earlier that I don't know why I wasn't thinking about that but uh with erc20 it has a Constructor so it has a its own Constructor so when you're deploying an instance of another contract you also might have to call its Constructor so this is how we do that we call this here and so in this case we wanted to do frogs and frog like this uh and then here we can do underscore mint so there's already a function uh that's available to Mint tokens okay so instead of us writing that that function or that that line of code to actually like create the tokens we can just call this mint function okay so what this will do is it will do uh one one two 3 one two 3 so it's a million tokens uh times 10 to the 18th I think we can do it like that let's see if that works yeah there we go okay now let's try to deploy again so um and we could also probably add ownable now I think as well so if we do uh well let's try to do that afterwards okay so we have the ec20 uh let's deploy it we already did it's successful now if we come to scaffold eth what you'll notice is we have complete token with just a couple lines of code as I wased before we had to like write all this different code so we have this token that has a decimals of 18 it has a name of frogs symbol of frogs it's got its total Supply but what's cool is it's going to give you all the functions that come in the other contract okay so since we're importing erc20 standard we get the allowance read function we get the balance of that we had to write manually last time we get the approve pattern for an erc20 where you have to like approve the spending of your tokens before they're uh able to be spent and we also get the transfer function and we transfer F where we can transfer from another address to another address if we have the approval so we it's a little bit more complete and it's a little easier to implement so you should always look and see if there's like a standard that you can use I always like to go to um cookbook. deev I don't know if anyone's heard of cookbook. deev but cookbook. deev is a really good spot to find contracts uh that you might be thinking about creating um and so you don't have to reinvent the wheel so if I come in here and like let's say I want to look at ERC 721 we can do a search um and we can find different implementations so here's a soulbound nft right so uh if we want to do a soulbound nft we could come here and it's going to give us an example of what the contract should look like also what's cool about here is you can download it uh with scaffold eth as well so you can click this little uh icon right here which is scaffold and it will basically download the entire package for you and uh it's basically an entire installation of scaffold eth and you can just spin up your environment with that exact contract inside of scaffold eth so it's super powerful okay so uh okay we have this token that we've created um we used erc20 standard um let's let's just I want to show you guys how you add another contract so you might want to add another contract at some point because you know you might have a more complex application so in this case we have it's called your contract so we also might want to do like new file and we might want to call it another contract like this like this and then we can grab this entire thing paste it in here but let's just get rid of some of this stuff and I don't know this we'll just say like uh get rid of the Constructor it's not in your C20 uh we'll just do uh I don't know would something like uh string uh hello equal hello world sure okay so we have this other contract that we want to deploy but how do we deploy it so we can if you're using hard hat you can come in here and create another deployment script so what I'm going to do is take this contract and make another deploy script so all you need to do is do a new file and do 01 underscore deploy underscore your I should say deploy another contract so it's going to go in order of the uh leading zeros so this one would be deploy first this one would be deployed second we can paste that in we also need to update instead of uh deploy your contract we want to replace everything with another contract so what we'll do is we'll find anything that says your contract and we will replace with another contract let's see if that works cool uh boom so now we're doing the exact same Deploy on this contract so now we have a new contract here that just says hello and we have another deploy script for it that's here it's called another contract so we basically we took this copied everything replaced everything that says your contract with another contract oh I'm missing one here there we go okay now let's try to deploy that so that should give us two cont cont s now what did I do wrong oh is it did I not do it completely uh here oh thank you thank you this is the best audience ever you guys are helping me okay cool there we go so now that should work so basically we have now we have a second contract uh now what's cool about scaffold eth is it will show you the other contract here at the top so we have this contract which is our erc20 the Frog token and then over here we have another contract which is just has this kind of like oh that's weird where's the variable for it oh it's not public so it's private so defaults to private so we need to make that public redeploy changes and now we'll see this kind of like string that shows up here there we go cool so you probably are going to make a way cooler smart contract right um you'll probably do some more interesting things um if you want to get some ideas of like smart contract stuff I would just like I said look through uh cookbook devb to see what kind of other um contracts are available for you to use uh if you're trying to like create a new contract um you know it just takes time to kind of like innovate and do stuff like that if you're new to solidity again you should go through solidity by example uh and just understand how things work there's also I don't think I talked about it but there's a great uh set of YouTube videos I personally like to Lear learn by videos so if you go to the smart contract programmers YouTube which is this guy um there's a bunch of playlists that are available uh for different things and uh the there's one just for solidity 0.5 examples and then there's another playlist here for solidity solidity 0.8 so definitely recommend watching both of those I think most the time that they might be embedded in here sometimes uh no so you kind of have to look them up uh I think he needs to like put links so it's easier for people but um yeah for the most part you can find for all these examples that are on the left you can find related videos that explain in like detail of of what each line of code does and why um he's a really good teacher uh okay so let's let's pretend that we kind of have this contract first of all I'll stop for a second and see if anyone has questions and then if not what we'll do is we'll try to deploy this contract okay to a test net so uh show of hands if anyone's stuck or has a question so far anybody good ber okay let's do this all right let me just make sure there's no questions here uh on this thing and then what we'll do is we're going to try to uh deploy this contract to a a public test now okay um so no questions looks good okay so the first thing is that um we don't want to use the private keys that are stored inside of um the different chains so we have hard hat or we have Foundry they come with private keys and public Keys you don't want to use that when you moving to a test net so uh the first thing that we actually need to do is take our uh implementation and we need to generate a private key okay our own private key so scaffold eth actually has a function for that so you can do yarn generat so depending on which uh chain you're using if you're using uh hard hat it's going to just create a EnV file with your private key inside of that that file that's what you should keep secret obviously and then it's going to give you your public key here okay you can also do yarn account and what this is going to do is it's going to give you a QR code that you could scan to basically fund that account so I'm going to go ahead and do that I'm going to use uh my punk wallet to send some sapoia eth here we'll deploy to sapoia so I can um I have scaffold eth was also used to build Punk wallet.io so if you guys haven't seen that it's really cool you can have this burner wallet inside your browser and you can fund it and it's stored in uh storage like the private key so it's not good for public stuff I wouldn't recommend it um but it's good for like test Nets uh so we have this ability to scan the QR code with the camera and then I can just send some eth to this deployer account so I'll send in 0.1 eth sure okay so I just sent that eth we'll give it a second so now if I do yarn accounts oh was there a question sorry I'm going to use sapoia yeah just because seoa is easy uh ELO base suppo is pretty easy um I mean shoot you can deploy to base these days pretty cheap so um but yeah let's see it might take a second for the uh thing to go through it takes maybe like 10 seconds let's see so if you do yarn account it goes out and checks the balances where did it actually go I hope it did that's weird let me just make sure that I got the address right uh I don't think it yeah that's the right address let me just try sending a little bit more okay your own account okay let's look at this let's look at the the scan uh sapoia ether scan and we'll put in this address and let's see if it has a balance it could be that the yarn account is not showing us the balance but it actually has one yeah so it has some eth it has 0.2 eth so I funded it from my phone send it over so now what I'm going to do is I'm going to I have a a deployer key now private key uh so what I can do is deploy my contract so there's a couple ways you can deploy your contract uh with hard hat you go into the hard hat directory and there's a hard hat config and inside of here we have a configuration of what uh deployment we want to use so in this case the default network is currently set to Local Host so we've been like doing everything locally but now we want to put it on sapoia so we're going to replace this with sapoia like that hit save and then now we're going to go ahead and do a deploy using sepolia so we could also if we didn't want to update the config we can also do-- Network and you can just type sapoia as well so it's either or right so let's just go ahead and do a deploy so what this is going to do is it's going to take a um the contracts try to compile it which it didn't need to and now it's going to propose the transaction and then try to uh basically do a contract creation so it's a little slower obviously uh so we got it deploying right now what did I do insufficient funds okay so p is expensive right now okay let's try to uh send some more funds say it's probably because the erc20 contract let's do 0.25 sure it's supp e we have lots of it so uh YN accounts let's try okay let's try now yarn deploy insufficient funds oh my gosh it's so expensive all right I'm just going to send a lot of eth I'm just going to YOLO like one e let's do it oh I don't have that much eth on here okay I got to get it from somewhere else uh let's do H right here let's do here let's grab the address sorry uh where's the address set boom I'm just going to send some eth from this other wallet that I have which has a lot more okay okay so we do uh send paste in that address and let's send I don't know eth we want to send uh should send like two sure what how do I not have that many funds oh thank you that wouldn't have been good uh yeah where's sa at one did I miss I go buy it where's sa it's in the bottom show test oh yeah thank you it's so weird cuz I have like some test Nets in the top there we go that's a a lot more okay let's try sending that to there okay uh in the log the log is showing balance zero are you sure you pass the accounts in the sepo network config the balance is shown zero I think it's a wrong account H because 0.2 is way more enough to deploy a simple contract that's weird though maybe it's I mean in the hard hat config file oh in the hard config yeah so sepolia accounts sepolia config sepolia config default Network sepolia yeah networks what's the private key yeah should be using deployer private key that should be right I think accounts you have to pass hyen Network SE and see what's the when you did Yan account I guess yeah let me just double check count so this yeah it doesn't look like it yeah what's that oh you you think oh you think I'm doing I need to do das Das Network flag here like that oh yeah but I yeah yeah yeah yeah yeah but I just looked on ether scan I I just looked on ether scan and I thought it said that I do though right if we go here here I have I have balance yeah so it it seems like it's checking let me just try this let me see if this will work something weird going on uh can you just import the private key into metamask and confirm the valid address I think it's two different accounts uh yeah yeah the do you have the private key there right yeah yeah what do uh see packages hard hats. EnV I think no it counts yeah it counts thank you all right let's see add account import account R key boom that works okay yeah it's weird yeah it's not oh it's weird yeah yeah I don't know it's some something weird is going on unless it's something with my something with the RPC provider it might be that actually yeah because I'm using a public the public RPC but okay well okay yeah I'm not sure what's going on it's very weird let me just double check the config real quick default networks ofia default I don't need to change anything here right for the deployer now should work this for named accounts so that should be like what it's using for local stuff but Foria uh do what oh like another Network I don't think that's what it is because he's right it does say zero here balance zero so it's almost like it's not pointing at the right Network or it's the RPC endpoint is wrong and it's just def faulting uh here like maybe this needs to change to Alchemy let me try just doing that real quick so Alchemy UHC let's see there spell right no there you can take another RPC from chain L yeah let me just try this real quick the demo gods do not like me today okay um come on there we go okay apps let's use this test one p I wonder if this will work if I just use this one I'm just curious more than anything oh you can you go to the packages directly and try manually deploying it like packages SL hard hatch uh yeah I'd prefer not to though it's using toolbox so the deploy function [Music] St oh this is main net but where's the bully at there we go let's try this sorry guys sorry we're having issues this is unexpected the good thing is there's like a billion videos of deploying oh yeah yeah let's just try to deploy let's see if it works there it goes so it's the RPC provider man we got to fix that scaffold e we just changed the RPC provider and uh because we were having issues with Alchemy blacklisting our our API key cool it's working now all right that's fun all right cool so uh we're going to deploy our contract now uh as you can see it deployed successfully tells us how much gas we got uh we have the typescript definitions we created now what we want to do is change our front end so let's get rid of this um we want to change our front end to ELO point to to sapoia now we're still using hard hat so we're going to go into the uh contracts folder or sorry the hard uh nextjs folder we haven't really touched nextjs we didn't do any front-end stuff but there's one config that you're probably going to want to know and that is the scaffold config.sys if you have your own API key you should put it in okay now let's go ahead and load up scaffold e again now you'll notice we got kicked out of the wallet so first of all let's take a look at the contracts uh these These are both going to be um unverified I think I need to actually update the RPC provider too I think the RPC is completely messed so let's let let me put my API key in and see if that works uh because it's already freaking out okay let's go to API let's copy the key and let's also put that in here save it and then you might need to restart nextjs if you do that let's try it again okay so now we're on sapoia we have our contract deployed on sapoia here so we can see that uh we can also see that we got kicked out of the burner wallet so we want to we don't want to use burner Wallets on a test net because they're stored in local storage so it's not really the most secure way uh so we now need to use metamask right so we're going to connect connect to metamask hit next confirm uh it wants us to switch networks we did and now we're on sapoia it has a I have a balance in my uh address I have the another contract which is just the hello world and then I have this year contract which is an erc20 uh and it should have a minced supply of burner wallet but uh oh you know what I I don't know who I Meed it to let's see let's take a look at the deploy script uh what did I do your contract deploy deploy your contract uh sorry where's the contract at your contract oh I sent it to the hard hat address that's okay uh either way we're not going to actually do a test anyways but I just want to show that we've deployed successfully here uh and we have this kind of like read function it so now we should be able to um see who deployed the contract so if we come here we can click on the address and we can see that here was when the transaction was done 3 minutes ago from this uh contract creation which is here um and yeah we can also see that it's not verified so the next thing you probably want to do is verify your contract so what we can do is come over here and let's this is going to be fun let's see if it works yarn verify D- Network sapoia so that's going to take the the the contracts and basically like figure out what the bike code should look like um based on the what's on on Chain versus uh sending the ABI to U ether scan I think is what it does and it's going to verify it so there we go now it's verified I think because I put my API key in it's good so it's going to be good yeah so there we go that one's verified this one should be verified now as well so now if we come back to Ether scan we can hit refresh and that contract will have a green check mark okay so that's definitely a cool feature of scaffold leth um because you want to verify your contract especially if you want to like use the graph or some other tool that needs the ABI that way the ABI will be publicly available um Okay cool so now we have our contract that was deployed it's successful um we could basically try to like interact with it let's just see if we can do that um see where's it at here we go uh so we can do like balance of italic eth it's going to be empty y cool um but yeah we can see that both the contracts are deployed so cool all right what else do we want to show off um we also might want to deploy this somewhere for like testing with like other you know users like you want to actually send the URL to someone uh so the next thing is you probably want to ship this front end there's a command for that with versell so we can easily ship the applications by doing a yarn um versel uh Co colon YOLO d-r which is the most awesome uh yarn command ever but what it's going to do is it's going to ask you to sign into to versell so you can sign in with GitHub uh or you can sign in with like uh basically like an ooth hook to uh versel and then it's going to ask you if you want to set up Andy Loy we say yes it's going to ask you if you want to use an existing scope of projects uh or what your project scope is so mind it's Kevin Jones creates it found our project I want to create a new one so I'm going to say no and then I'm going to not link it to an existing project I am going to do it to a new one so I'll just do this I don't know Devcon demo enter it asks me where the code is located I can just hit enter and now it's going to set up the project so what it's going to do is like uh create the config file uh for versell and then build it make sure it builds properly uh set the ports all that stuff like that and then it's going to ask if you want to modify the changes you say no and then now you can deploy it so it's going to push it out here so if we come to this URL now uh it takes a second to deploy we can come here paste that in and oh I need to be in the right browser session which is a little annoying so by default versell like will'll make it private so you need to like authenticate and actually sign in to versell but uh as you can see here it's building so that will take a second so it's already kind of like transferred all the the files to versell and now versell is running some Automation and basically creating a page for me so this point then we'll have this kind of like deployed application uh we didn't really do any friend end code but like I said Eda next uh tomorrow she will do a much further um demo um and show you how to use the hooks and the components reading and writing from your contract uh and and stuff like that okay cool I want to talk about one more thing um first of all let's stop for a second sorry about the hiccups I'm glad we were actually able to deploy the contract uh but are there any questions uh up into this point that I can answer y eah network not supported uh did you do yarn verifi D- network uh yep and you type sapoia no I use base base uh it's base mainnet maybe uh so if we go into the hard hack config so the question was uh he was trying to do his verification but it said network not found so I think what's going on probably is inside of the hard hack config we can take a look at what base is called so I think it's called base oh maybe it is called base yeah B Yeah so basically the error message says network vinity 8453 not supported you can specify the URL manually bya API URL oh maybe you can't verify contracts it's possible uh that you can't verify contracts for base possibly um so there might be a a ual URL you can pass with the API key using like base uh base scan or whatever it's called Uh so there's probably a way to do it you need to go to the base uh block Explorer and go to the verification for that contract and it will tell you how to do it cool any other questions yeah uhhuh let's get get your a mic first yes thank you uh I would like to know where to specify the API key for the blog Explorer because to verify uh what I that you need the blog Explorer API key so in the in the structure of the project where do we specify this key yeah that's a good question um so I think there's a um let's see if I can do this yarn verify d-el maybe I don't know if that's going to work but there's a there's a way to do that D- API key so you can say yarn verify D- API key and you can also specify the URL manually so yeah it's using hard hat verify so if you want to look up the documentation for hard hat verify that's exactly what it uses at least what my implementation is if you're using Foundry it's going to be different I'm not sure what they use yeah and when you you verify does it ify all the contracts or yes okay yeah like scaffold eth is not like multi-chain out of the box so it's just going to assume that you want to verify all of the contracts in that project if they're already verified it we'll just skip them yeah another question over here um so B basically a scuffled is for uh nfts and staking apps assuming I would like to do like a computation and add it uh to a Smart contract from using I don't know graph Computing or something is is this possible with scaffold e or is this more for like staking apps and NF I mean you can you can write any evm smart contract with scaffold e um so if you want to do that inside of the smart contract then yeah yeah you can do whatever you need any kind of smart contract logic anything you can write in solidity you could write with scaffold eth right but is it what is the the is it made for that or is it made for uh the examples made on speedrun ethereum is it made for computation actually or was it made more for like um DBS like staking and so on yeah it's made more for DS It's not really made for like decentralized compute aspect stuff like it's not a I mean yeah I'm not sure I'm not sure to answer how to answer it but but basically it's it's just an ethereum you know tool for building and writing smart contract so anything with solidity but daps yeah yeah cool we can talk after if you have more questions yep cool any other questions sorry it's hard to see you guys too I'm like blinded okay cool I don't think anyone else has questions no cool all right now what we're going to do next is since we have just a little bit more time I just want to talk about the extension system looks like we got like uh yeah not sure how long uh maybe like 20 minutes 15 minutes or something so let's talk about extensions um there is if you go to the scaffold e website scaffold eat.io and you go to docs and you come down here there's a section called extensions so uh I talked about this yesterday um you can probably find the talk um available later on after they upload them uh where I actually show off an extension I probably don't have time for that but there's a list of available extensions here um one of the extensions that I would recommend you check out is the subgraph one uh because it has the graph implementation there's also other ones like onchain kit and different uh eips as well as Ponder um and then you can also create your own extension so it's pretty cool if you are a developer and you want to like showcase scaffold e how it integrates with something um you can build out a extension and add the functionality you want and then every time you want to create a new project you can just use that extensions framework to start at that point so really powerful and also if you go to scaffold E.I and you scroll down there is a section that is all about components and there's an extension guide here uh and then we have the check out all the available extensions so you can do it like like I said before you can do the- e flag and you can pass in a URL on GitHub um and then here we can get a list of uh extensions so here's the subgraph one EIP Ponder erc20 onchain kit there's a bunch of other uh third party ones that have been created uh so we'd love to see what you guys uh build there's a chain link one so if there's something you're trying to do uh with with u you know another integration you should always check here there's an a Fleek extension which uh is really cool you can deploy to Fleek so if we didn't want to deploy to verell we might want to deploy to Fleek you can use that so yeah check these out highly recommend them and um those are going to be a good point to uh start um and then El speedrun ethereum so I just want to talk about speedrun ethereum a little bit more so speedrun ethereum uh when you first come here you can connect your wallets and it's going to uh create a profile for you with your address it generates this little like Punk uh and then you can come in here and go to the main speedrun ethereum page oh let me reconnect and you can start a quest so like the very first one is very very simple so I guess my recommendation for anyone that's new to ethereum try to do this challenge because all you have to do is do the first part of what I did set up scaffold eth um and it's going to let you create this kind of like NF uh uh tool it's like just nft um with these little like kind of fun characters um and it's going to walk you through everything you need to do so it tells you what you need to install it tells you how to get the repository go into the Repository check out a specific Branch so it's a little different than just the standard scaffold eth installation because it is a g GitHub repo right here uh and so each particular branch is the the challenge so if we go to it we can show what that looks like here we go oh did I type it in that's weird huh that's weird okay let me just check the scaffold website what's it called it's uh SC2 challenges so we go to repositories SE to huh they renamed the repository okay there it is okay so this is the challenges repository um if you click here on Main you can see all the challenges here so zero through all the way down to seven SVG nft so um yeah you can just choose that repository and then each one is going to have all the instructions as well here so you can do it either way but when you're ready to actually submit your uh your progress you come all the way to the bottom and you hit submit Challenge and it's going to ask you where you deployed it so earlier I showed you guys how to deployed to verell which we should have done actually let's see if it it went through successfully Uh Oh shoot what did I did I lose it I had it here I don't know where it went anyways uh it it will give you the URL that I that I typed in and put in so you need to put that URL right here and then you also need to put the contract address that is verified on uh ether scan uh so basically it's going to ask you to deploy everything to sapoia so you just need to put that seoa ether scan the contract also needs to be verified because we do some automation to like verify uh your contract so I would recommend everyone try to do at least challenge zero before the end of the week it literally will take you like 20 minutes to do um and then that will kind of set you up to start learning a little bit more and then you can learn uh again how to do like uh staking so this will go into like how you stake uh use you do like token staking uh this is how you do like a token vendor where you can actually like deposit one asset and get back another uh and then again this talks about Randomness and then eventually you build like a DEX which is a lot more complicated but you learn a lot because then you start to learn about uh you know slippage and and and stuff like that and um understand how a DEX Works decentralized exchange cool okay cool I think we're going to probably end a little early unless there's questions does anyone have questions at all yep question here yes I would like to know when you submit your challenge is it verified by human being beyond the s or is it automatic do I need for example to send a video to show that my Contra respect specification yeah so it's all automated pretty much we just uh the way we do it is we well the first few challenges we do automated so we just get the The Ether scan address and then we pull down the source code and then test it so we run like a test so each challenge has a test so if the hard hat test passes on your local machine it's going to pass on the automation so we we verify it when it gets down to the decks it's done all manually so we actually look at the code and make sure that it's it's good um you don't need to do a video though um and especially these last few like the state Channel multisig and SVG those are also all manual pretty much yeah what other questions we have I think I saw another hand but I don't know where it was no no cool awesome thank you guys so much for coming and I hope you guys learned something and it was useful thank you [Music] [Applause]
