Getting started with 🏗scaffold eth Austin Griffith & Kevin Jones
ETHGlobal·Sun, Oct 9, 2022, 12:00 AM
Speakers
Welcome Austin Griffith & Kevin Jones from scaffold-eth for a workshop titled " Getting started with scaffold-eth". ETHOnline is our biggest event of the year! Collaborate with thousands of developers and creatives from around the world and win over $300k+ in prizes! We're bringing in 30+ of the biggest teams in web3 to give you access like never before. Learn from ecosystem leaders and build your biggest ideas as the merge nears reality. The future of Ethereum is being written right now, and it's time to make your mark. --------------------------------------------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com #ethereum #eth #blockchain #crypto
Transcript
[Applause] [Music] all right we are live um good morning good afternoon good evening depending on where you're calling from we have really exciting workshop featuring austin and kevin doing a joint workshop on getting started with scaffold eat questions go into the zoom chat if you have any and that being said i'll pass the mic off to our two speakers awesome thank you for having us i'm austin griffith here's kevin shutter block what some of this some of this what what what some front rails all right here we go let's just get let's dive right into it kevin thanks here for being here just in case uh i go into labor and i can't be here kevin was here to back up but we're gonna do like a like a dueling keyboards dueling banjos kind of thing gm in the chat uh first thing i want to show off is scavenge okay so we're gonna do a quick like five minute intro to what is scaffold eat and then cut what did i do and then kevin will take over and we'll build something quickly and we'll deploy it and then i'll build something to maybe try to attack it and play around with that okay so scaffold eaves scavenge is a starter kit you're about to take uh over and start building something for the next month for eth online uh the hackathon stack the hackathon stack is scaffold eve you can use scaffold eath to quickly prototype an app it helps you kind of get a feel for how your solidity works and help you helps you deploy something quickly and get that in the hands of other folks can we hit admit for all these folks that are coming in is it okay if i'm hitting admit and just allowing people in hope that's cool because i'm just admitting people okay here we go uh let's see the the first thing i want to show off is how you can live edit your smart contract and how it will auto adapt so with scaffold eth you'll follow the instructions here you'll clone it down you'll do a yarn install you'll do a yarn chain and that will fire up your hard hat node then you'll do a yarn start and that will fire up your front end react app and then you'll do a yarn deploy right here and that will deploy your app uh locally to your to your to your local blockchain now this is where it gets interesting because we can do an atom and we can edit our smart contract here and we can see our interface for our smart contract over here and this is kind of the this is the initial kind of setup that you want to have with scaffolding you want to be able to uh add something to your contract like an address public owner and set it equal to whoever this dude is right here and you want to be able to do a yarn deploy oh man my i need to kind of have this organized a little bit more and do a yarn deploy over here and this is going to deploy your app to your local chain and notice this auto adapts to it that's the key i'm trying to show here is you add something small to your contract and then you see it show up over here let's change that owner to this address for some reason and do that deployment again and now watch over here as this should change actually we'll get a new contract and that red one will move down there okay cool so we're in this live kind of feedback mode where we can change something quickly in our smart contract and we can interact with our smart contract so so this contract object right here is really nice because it auto adapts to whatever you've added to your smart contract so uh let's let's just look at this contract real quick we've got an event we've got some storage here right so this is a string uh purpose that's stored on on on the is stored in the smart contract basically on all the nodes on all the network that's why it's so expensive and we have a set purpose that lets us set that that value right so over here if we wanted to go ahead and try to set that purpose i'm gonna grab some funds from the faucet and i'm gonna say hello world and that should let me set that purpose right and uh let's let's add let's add us something a little bit different let's go back to our addressed public owner and set it equal to this guy again okay and then let's create a require statement probably one of the first things you learn when you're building something in solidity is a require statement and the second thing you learn is global variables one of those main global variables is message.sender you can you can learn this by looking at global's uh solidity globals right we can go find where these are and this is kind of how how you kind of get started working you kind of have this iteration cycle where you can make changes to your contract and you have reference material like the solidity docs and solidity by example and you kind of grab things from over here and paste them in over here and kind of get them to work so right now we're looking at message.sender and we want to make sure that the message.sender is equal to the owner or we're gonna throw some message we're gonna say not the owner right and we'll go ahead and save that and we'll yarn deploy and so that is gonna set us up with a smart contract where only the owner should be able to set the purpose so let's try a hello world and hit send and we are the owner so it works okay so here's where we're gonna learn about burner wallets if i do if i open an incognito window notice this account is kind of like this yellow and green guy and if i hit new and i go to localhost i get that yellow and green guy again but if i open up an incognito window and i go to localhost i'll get a different account see now i have this like kind of red red account right so i'm gonna give them some money from the faucet and i'm gonna go ahead and try to set the purpose and it should say something like not the owner awesome okay so we were able to create a second account and attack our contract and prove to ourselves that this require statement is working and that's kind of like the the key piece that i want to get you started with with scaffolding you need to be able to experiment you need to be able to test your assumptions and this will help you kind of do that very quickly uh the faucet kevin will show off burner wallets i've showed off uh the deploy script okay so then actually i'll show that off in the next section too let's not worry about the deploy script right now we've got only owner and we've got okay so uh i think now i want to hand this off so basically i can get into this mode where i can write this stuff all day and i can tinker with my smart contract the next step though is once you once you have something built you'll want to deploy it to a live network so i'd like to throw it over to kevin have him build something quickly and then have him deploy it to a live network like covan and then i'll take over again and kind of interface with his contract but there we go we got it awesome you want to go ahead and start talking to i'll kick it off too yeah yeah absolutely so yeah i've basically gone ahead and i've checked out scaffolding then i've already kind of spun up hard hat in this top left corner and i've already spun up react in the top right hand corner uh so what i want to do now is actually just uh load up the the smart contract and we're going to kind of just like gut it a little bit right we're not we're actually not going to be doing the unstoppable apps we're not going to be setting a purpose for the smart contract uh what we're going to do is we're actually going to build like a smart contract from the ground up right um and what we want to do first is is basically create a mapping we're going to create a bank we're going to create this bank that kind of like stores value and uh we can actually utilize the smart contract to keep uh track of the balances of who interacts with that so one of the things you'll you'll learn with uh with solidity is you want to might want to create a mapping where you map one variable to another variable and keep track of that right uh so we're gonna take uh the address uh that is coming through and then we're gonna map that to a uint right you unsigned integer right and then we're going to make this uh publicly available and we're going to call it balances so this is going to keep track of all of our balances right and then what we want to do is create another function that is going to be a deposit so we're going to say function we're going to call it deposit and we're going to on this one we're going to make it public and we're also going to make it what's called payable and the payable function is exactly that it's just a function that can not only you know be called in the transaction but it can also receive some value right uh austin talked about global variables and one of those things is the message.value which is how much value is coming through the transaction so what we're going to do is just allow someone to call that if they make a transaction and then we're going to take the balances of that particular message.
sender which is you know whoever's calling the actual contact uh contract and then we're going to add to their balances right and we're going to do that by inspecting what the message.value is for that so let's go ahead and do that let's save this contract and let's go ahead and redeploy and we can just do a reset just to make sure that we get a new instance of the contract and let's load it up and see we should have a completely new uh transaction that was deployed looks like it worked and damn boom so now we have a new contract and we have a balances function which is basically just to look up the balances of a particular address and we have a deposit function so um austin already showed that you can just quickly grab some funds from the faucet but let's grab some more funds this is only going to give us .01 ether we actually want to grab a little bit more than that so we can just click that little thing there and actually copy the address and we come down here to this uh this i guess larger faucet and we can grab more funds so let's paste that address in here we can switch this to ether and then we can grab like 10 each from the faucet and this is going to pull funds from hardhat and put them directly into our burner wallet that we have in the browser you could also do this with like metamask if you had metamask there but you see now that we have 10 ether which is a total of 15 uh almost 15 and a half thousand dollars and so now i can do a deposit i could say well i want to deposit one ether and you'll notice here that when you know whenever you're transacting on your smart contract you need to do it in way there's this cool functionality right here that allows us to do the the math for uh which is basically going to calculate how much weigh that we're uh putting in here so if we were to put in 0.5 ether we could click this and it would translate to how much way we need to send in the deposit but we're going to do one whole ether so let's do that and then let's send that and we can see that it was successful and we can see now that the smart contract received some funds we're seeing some value so it's got some value it used to say zero now it's got some funds but we made a mistake we didn't have a withdraw function here so we need to actually add that right so let's go back and let's add the withdraw function uh so for this one we're gonna do function withdraw and we're going to make this one public as well and then for this one uh we're going to do message.sender so this is the the person that's calling the the function and we're going to do what's called a call which is basically when you want to extract a value from the contract you do a call and we're going to send in the value of that call as an amount that is going to be taken over um in the smart contract okay and then let's do this and we need to take in that amount so we're going to take unt 256 to take in the amount that we want to do and call that amount so this function will will uh allow us to specify how much we want to withdraw in that amount and then we're also going to uh we're going to do what we're going to make shifting this yeah a little bit disclaimer this is definitely yeah not the way you would normally do it but to showcase some some shady stuff that you can do on ethereum no uh so we're going to do what's called unchecked which is basically just going to not validate um i guess the syntax i know maybe you can explain that a little bit better austin but we're basically going to uh update the balances after we actually do the call which is probably the most important uh function or i guess um a thing of the function that we're doing so we're going to take this and specify the amount and i think oh this is always good there we go and unchecked and then yep okay so there's two things happening unchecked we're doing unchecked math and that means that if you roll over or you cause overflow it's not gonna throw an error basically uh so you see that we have solidity eight here solidity eight is going to bring the safe math safety stuff automatically and so by doing unchecked we're going to allow for us to do some unsafe math and in combination with the fact that you're doing a call and then you're updating your state that's that's basically a reentrancy uh any smart contract people out there should see that we're updating our state after we're doing our external call which makes us uh exposed to reentrancy but then on top of that we're doing some unchecked math so if our balance is overflow uh it it allows us to do that so both of these two in combination are going to make it exposed to a reentrancy attack and we're going to go ahead and pull that off in a little bit looks like you're about to add your deposit function go ahead and do that first and then before you switch over to me oh and we still got to deploy this whole thing too yeah we got to deploy it so let's keep going sorry we're getting there we're getting there this is the fun stuff all right so we're also going to call the deposit function on the receive uh i guess not the fallback but the receive function which is under just the x uh the default receive function so that um when someone does call that they'll also uh in turn call the deposit function where that's where that those funds will go so we keep track of the balance so let's say that you can yolo money directly to the contracts address from your wallet without calling the deposit function and it will automatically deposit on your behalf and and mark it in the mapping as part of your balance right so now we got we got a new field we got the withdrawal function right so uh we don't we got the funds here the the contract's empty so let's go ahead and deposit another each let's do that directly to it instead of instead of positive yeah grab the address and use your wallet yeah and then let's just go to the wallet oh sorry that's the wrong thing that's uh not the right thing so you go here to your wallet and i can say oh well let's just send some funds here and oh oh sorry that's not the funds let's send we got to grab the address first so let's grab the address for the smart contract click the wallet paste it in there change this to each let's send one whole thing to this smart contract send boom and it was successful i believe now that we can query that balances for that contract boom it works so it kept track okay cool so i'm going to leave that ether in there and we know that it's working but now we need to deploy so we have a smart contract we've kind of tested the assumptions of what's going to happen and we want to deploy it now so the first thing you need to do with scaffolding is you want to create a deployer account so we're going to do what's called yarn run generate yarn run generate is going to basically generate a mnemonic store it in your directory of your instance over here you can see that it just appeared it's basically the um sorry let me hide these panels uh it's basically the the password right the passphrase that's used to generate never share that normally yeah yeah don't really share the screen but so you should um should actually delete that one and do another yarn generate just so we don't expose that all right yeah let's do that we got jabroni's on this call who knows they're gonna they're gonna drain us generate a new one yeah there we here we go now we're going to do a yarn account which is basically going to take that mnemonic uh account and it's going to give us a qr code that austin you're going to help me out with right we're going to try to fund this with some coding so here we go let's go yarn account it's going to give us a qr code and hopefully you were able to scan that yep all right sending you a hundred dollars worth of covan should be sent from a punk wallet at punk wallet dot io built with apple leaf all right you should be good to deploy to covant now let's try all right so now we can do yarn deploy uh dash dash network uh coven like this and boom we can deploy our smart contract to coven because we're using that deployer account that austin funded using that qr code and it said reusing your contract do a dash dash reset thank you for some reason that contract already exists on covan or something i don't know we need a refresher oh yeah it's because we were okay so dash dash reset um space dash network covering like that yeah that should work wiga almost tricked us with hard hat deploy we'd like to give us a fresh one right yep you're right good catch all right and then you let's see you need to get your app working right so you'd put your app on covant should we go make a deposit to make sure that works let's do that real quick uh let's go to the app.
jsx file so uh when you go to app.jsx um it's your basically your your the scaffold leaf component the main component for your app you know all you got to do is come over here change this to covan hit save and then uh now our app we should be able to refresh and i've got my metamask account that i can sign in i can switch to the right network because it detected now that the app is on covan and i should have some play eth in there i do okay so now i can actually because this network because the smart contract was deployed successfully it's on coved now so now i can deposit so i'll deposit one ether and send make sure we sign the transaction and make sure it's in my network yep yep covant all right here we go so now i've deposited that each now it's processing obviously it takes a little slower on a test network uh oh while that's doing that i'm going to do a yarn build yeah or sure or no yeah you could get it yeah let's do it so your build is going to basically package it up in case we want to deploy it search later which we might want to do so yeah another thing is verifying the contract but you can do that in a little bit also yeah let's just make sure this balance works it looks like there we got a response back there we go okay so you have one each locked in the bank on behalf of crypto mastery and now our goal is you hand it off to me go ahead go ahead and verify your contract and deploy your app kind of in the background but hand it off to me and i'll take over and i'll start working on kind of an attack contract but you should hook me up with the address of that contract real quick i just said it's doing a telegram okay awesome awesome okay so let me steal the screen from you let's see okay there we go you got uh got that guy there you can see uh an empty contract basically so i brought in your bank right so i'm kind of creating a little interface up here since i want to talk to your contract i know that your bank has a balance i know that it has a deposit function and a withdrawal function so what i'll do is i'll instantiate that bank here and let's make that public so we can see it and then i'll have my constructor taken an address bank address right bank address something like that and then i'll go ahead and say bank equals now if i were to say new bank this would be a factory contract and it would be deploying a bank contract but if i take that new out of there then it's going to talk to an existing one at some address there we go so now we've instantiated a a link to from my smart contract to your bank right and then what i want to do is i want to have some function that we'll call uh attack right and it will be public payable uh it will take in some amount and what will it do okay so let's see i think what we want to do is deposit what do we want this to do we want it to uh let's let's not let anybody call it first let's let's like uh limit this to only uh my metamask account being able to do this so we'll do message.sender must be equal to me or i'll say not austin just to set it up so only i can do this attack function i guess idk and then uh what are we going to do we're going to do bank dot deposit so what i want to do here is i want to do a reentrancy attack i want to deposit some money and then i want to withdraw it and when i in the process of withdrawing it it's going to call my receive function then i'm going to have a little bit that i'm going to flip and say okay i've already attacked it and i'm going to withdraw one more time so i'm going to for for one one eth withdraw i'm going to withdraw to eat and i'm going to steal kevin's eth from the contract which is it takes kind of two mistakes basically he has to have his re-entrance he exposed and he has to have unchecked math but we're going to try it out here so i'm going to do a bank deposit of let's see this would be i'm sending value here right so i need to do message.value [Applause] so i'll send money into the attack contract and it will it will then take all of that money and immediately deposit it into the bank and then it will immediately withdraw that same balance okay and uh the amount will be message.value okay so at this point i basically just put my money in and pulled my money out all in one attack and uh maybe we should just save that and yarn deploy it first uh let me do a yarn generate on my side and a yarn account let's fund this guy we're going to go straight to uh kovan with this dude we're going to be testing in fraud here we only have 30 minutes total so let me go ahead kevin were you going to say something oh double check your deposit someone mentioned that maybe it was a typo as if and they're good oh man good call right did i did i spell that wrong let's make sure thank you chat [Laughter] okay uh there we go so i need to i need to send some kovan to this dude maybe i already did let's see just in case let's send some more covan use a punk wallet here oop oh yeah i already sent some here send some more all right so yarn compile right let's make sure that recent change that i just put in there it won't be ready to attack we'll do we'll do a second step to attack but let's do just a yarn deploy and put yarn deploy dash dash network covan okay there's an issue the deploy script i wanted to talk about the deploy script and this error is telling me something about the deploy script uh this constructor takes in an argument so we need to put that in here so in scaffold ether use hard hat deploy and it uses these deploy scripts here and here's where you would put in an argument and that's what we'll do uh we'll put in uh i need your address right i need the address of contract there we go so i'll deploy my contract kind of pointing at your bank let's see if it likes that oh i think it's going to i think it's going to okay let's just see if we can deposit and withdraw all in one thing and make sure this uh transaction works and then we'll we'll add a little complexity to this we'll add an attack next okay okay looks like it is okay and then i'll do the same thing i'm going to take my app notice we've we've we've had like three different instances of scaffolding here all talking to like the same contracts that's the just the power of composability of ethereum and i'm gonna set this to covan and hit save so now i should have a front end that lets me see my attack contract out on covan uh we used a lot of burner wallets when we were doing local development but now we're out on a public network so we'll connect our metamask okay and it's not even gonna be an attack basically all this is gonna do is do a deposit and a withdrawal and it should work but let's just try it real quick let's just do 0.
01 eth and let's make sure this works basically it's just going to deposit the money and withdraw it immediately we won't even be able to see without any events or anything we won't even be able to see if this really worked uh another thing we can do is click on the bank and we can make sure that that one ether is still there looks like it is well what are they saying about covant is kovan going to be depreciated too oh no sad off to gourley i guess we're i guess we're off to gourley okay so uh it seems like our attacker contract at least can successfully deposit and withdraw 0.1 all in one atomic transaction but here is where the magic happens here's where it gets really interesting so let's just let's just do this uh when when we deposit it puts the money in and then the next step it withdraws the money out and on the way out it's going to land back in our contract and it's going to trigger this receive function just like kevin was able to send money directly from his wallet to his contract and the receive function caught it and deposited it we're going to catch that and we're going to do something here right we're going to execute we're going to do some kind of execution here so basically i just want to attack it just one more time i want to put in one eath i want to withdraw my eath and then i want to withdraw one more each and the way i'm gonna do that is just set up a bool that's like has attacked and we'll set that to false right it'll start us false and then we'll say something like if we haven't uh actually if we if we have attacked already we'll do nothing right and if we haven't attacked yet then we'll set has attack to true and then we'll do our attack and our attack is incredibly simple it just withdraws some amount out right i'm just gonna set it to one ether i'm just gonna hard code it this is not the way to do this there's a lot of like little subtleties here that you could change to make this better or make this make more sense hopefully it makes just enough sense to you as a scava leaf builder that you can kind of follow this a little bit but let's go see what's going to happen here hopefully this thing will compile i'm just going to deploy it whereas we're just sending it just i'm probably missing something but let's see what happens here and we got maybe like five more minutes here we got plenty of time okay let's see what happens here so your contract is still out there we'll see this change too there we go my contract just updated so now i've got a new contract here uh did you verify your contract too can i go see it yeah oh very nice look at that verification we can see the source code good work dude okay so uh let's steal this ether right that's the goal here uh let's basically i just put in one and i hit this and i hit attack and it either works or it doesn't [Laughter] moment of truth here we go drumroll it might work it might work okay here we go oh you know what i didn't put on did i put a withdrawal statement in here i didn't it's basically going to pull the money and it's going to land in my contract and it's going to be locked in my contract forever but that's okay we're doing it that's fine right what i needed to do here is send the money to myself the money's just going to end up getting locked in this contract should we should we should we let's let's do it real quick with the job we got time yeah let's see function withdraw public we only want me to be able to do it actually we don't even care we'll do this we'll say it just like anybody can call it and it just withdraws it to my address if anybody clicks here right dot call and let's see the value is going to be all the money in the contract so we would do address this dot balance super weird line of code here uh that and i think sometimes people put quotes in there idk okay so if someone calls the withdraw function it is going to just send the whole balance of this contract to me let's see if that uh let's see if that deploys i'm not even checking i'm not even like compiling i'm just saying deploy it to covan okay so there's a little warning here that says that the low level return isn't used sometimes what you could do is you can you can set the result of this and you could uh set a require statement and require that that send to be true but we don't even care we're yellowing here there we go all right so now i have a new contract over here and this one has a nice withdrawal function so if we steal money to it we should be able to withdraw okay here we go moment of truth let's see if we can send in an eath with drugs and then on receive grab another one back right let's see if this works and we'll know if it works if well our contract will have two ethernet right let's see what happens here please work first try here we go come on re-entrance the attack will it work will it work oh contract's the contract is empty right if we go here yep okay so what what i want to do is i want to go to your screen and i want to show that you still have a balance and i want to talk about the contract that you wrote and show people how to basically make it secure uh let's see one last thing maybe let's make sure my withdrawal function actually withdraws it to me and we have created a reentrancy attack right this will go up a tiny bit hopefully there it goes yeah up to five we were able to create the attacker contract attack kevin's contract withdraw the money and i'm headed to mexico or something i don't know what i'm what i'm going to do yeah okay kevin and i are going to mexico all right here we go so let's make this secure let's fix let's fix our our errors here yep yep so first of all first of all if that ever rolls over we want it to throw an exception right right you update the balance you go right we want to update the balance first right here because otherwise you know um something like that yep yep and again we have safe math so if they try to withdraw more than they have in their balance it'll throw an error and then if i try to re-enter your my balance will have already been subtracted so basically that's how you fix this reentrancy bug by just simply uh doing things in the correct order and using safe math uh oh i was gonna steal the screen one last time before next steps okay so you've you've figured out how to tinker with scaffold eth you've built a few things you can kind of get in this iteration loop where you can deploy things even to test nets let your friends share and use your apps what's the next step where do you go from here even even if you're out there and you're like dang i don't even know where to get started was to have a leak this is there's a lot here there's a lot going on the best place to get started is speedrunetherium.com if you go to speedruneetherium.com and i'm throwing it in the chat right now you should be able to see some challenges here basically it says the same thing we just said here get scaffold eat downloaded locally go through these concepts in solidity by example looking at the solidity docs copy paste stuff test your assumptions then when you're ready we have a handful of challenges ready for you a simple nft example just gets you started it teaches you about burner wallets it teaches you about how to get scaffolding set up it teaches you about uh the nft contract and also going to a public network looks like we go to gourley someone has already i think this was this was rinkaby yesterday someone had got in here probably jason shout out to jax i bet uh he you you need to learn how to deploy to a public network just like kevin did with his covan deploy and this first challenge will teach you that then the next challenge really teaches you the superpower of ethereum it's it's allowing you the builder to create a simple set of rules so that an adversarial group of players can work together and that's let's zoom in on that this is this is about uh people who don't trust each other right you only the only thing that you have to trust is that middleware that that code layer and it's your job as a programmer to create the correct rules and the correct incentives in that middleware that code layer that everybody can trust so people that don't necessarily trust each other can get in and use your app to coordinate uh financially and that's what challenge one teaches you it teaches you how a smart contract sometimes is like a state machine and you kind of need to move from one state to the other and and it doesn't nothing happens automatically you have to poke it right someone has to make the transaction to move it from one state to the other you have to write your require statements correctly then you move on to a token vendor you deploy an erc20 token you deploy a vendor you learn the dreaded approve pattern and when you want one contract to grab tokens from someone else you can't just send them in and have it execute you actually have to approve it with one transaction and then call it with another transaction the dice challenge teaches you about randomness random this is super tricky on a public deterministic blockchain this is going to teach you when you can use block hash and when you can't and how to build an attacker contract to uh steal from weak forms of randomness in a simple test net game you're you'll become eligible for the build guild you can find out what the build guild is later uh then there's a dex you you'll build your own decks this is when you're gonna kind of you're you're hitting your stride you're getting good at things this this dex is uh susceptible to slippage attacks and stuff like that but you don't need to know that this decks will just teach you about reserves and lp tokens and how uh distributed a decentralized exchange works and then you'll create a multi-sig wallet you'll learn about different ways to store your eth and how to use a signature based system and then on to kind of like an svg nft and some more challenges that we're working on the key is go speedrun at the area this will get you started with scaffold eath it will get you started learning how to be an ethereum developer it will get you right to the solidity first and then kind of work you out of the onion through through all the other concepts anything else to add there kevin did we did we slay it what do we have left oh that was awesome yeah i think that was really cool um oh the last thing if you guys have problems you need help there's a telegram chat so if you uh go on to scaffold deep io or actually i think i don't know what the best way to be if you just search scaffolding telegram yeah yeah it'll show up and there's like 2 000 developers in there and they're awesome uh great community of developers who will help you if for some reason you know we're not available i think that's it i think we got it i think we're done yeah reentrancy on covant we did it we had to like we had to do a lot of work to make that that contract uh insecure it actually was hard at this point i mean trust me it's easy to make mistakes but it was hard to get that re-interesting to work it was throwing on us when we tried this 10 minutes before the call and we didn't realize we needed to do unchecked math also but i think we got it thank you eth global for having us thank you all for coming along on this fun journey don't forget to speed run aetherium speedrun ethereum and uh good luck hacking and build on scaffolding yes go get scaffolding get it started this weekend so you're ready when uh what is it tomorrow does the hackathon start tomorrow take take a moment tonight just to do challenge one or zero and one and you'll be ready for the hackathon tomorrow awesome um i think you have a question by daniel um what are your opinions on tdd with smart contract development oh cool yes so tdd would be the block difficulty and after the merge block difficulty is going to become this previous ram dial so it's going to work very much like the block hash where it's a randomness that's from the previous block hash that you could have guessed so if you and and by the way if you want to learn about this stuff scaffolding has like five different branches using different forms of randomness uh and we're even working on a future tdd and i think that's the that's going to be the best kind of cool randomness obviously there's like chain link vrf and and other kind of oracle random sources but what you can do is you can say a future block is going to have a specific difficulty and you can build your app to basically you make one transaction that's almost like a bet on a future block and then after that future block has happened you can make another transaction if your bet was successful you can turn it in and it'll go look at that previous block difficulty and it will pay you out based on that that it works with block hash a lot easier but what we're finding with using future block difficulty and this was a shout out to light client he came up with this uh yeah well yeah we would have never thought of this but he he uh you know dropped some sweet knowledge on us basically if you want to have uh difficulty difficulty isn't something you can query for a previous block like you can with block hash what you do is you have them submit the entire block header all the information that has to do with that block header and you hash it in the smart contract and you make sure that hash is equal to a specific previous block hash and if all of that is true then the block difficulty they submitted is a good form of randomness so it's complicated go through speedrun ethereum take on the dice challenge first uh but we do have a future block difficulty build in motion if you watch the scaffold e3 ray pose uh shout out to a homie damn who's working on that yeah i think that's i think that's answers the question i didn't see that question are there more or did we cover them uh could we use scaffold eat and other networks as polygon uh yeah so it's evm compatible so anything that's layered two that's evm compatible uh will work right basically yarn deploy dash dash network polygon and it's gonna work uh watch that sometimes you might get an issue with gas you need to go into your hard hat config and look at the gas for the different networks i'm going to look at polygon right now it actually does have a gas price hard-coded in there i would pull that i would let the rpc here you'll go if you go to your hard hat config right here and you go look at polygon it does have this gas price hard-coded i'd pull that out i do i do that right there and i deploy it just like that uh and and i think it'll like automatically get the gas price and i think that'll give you a better time so if you are having problems deploying to a specific network keep an eye on that config file awesome well that was a lot of fun austin uh really cool to uh to do this collab so thank you so much awesome oh thank you to the both of you austin and kevin that was super fun to be a part of and watch um for really thank you to two of you for taking the time to do this workshop for our eat online um hackers which is starting this week so super excited to see what everyone builds um and i hope you all learned a lot from this workshop i think austin and kevin have this like really great like and fun dynamic so it's super like engaging and fun uh but yeah otherwise i hope everyone has a great rest of your day and see you at future workshops thank you for having us here guys thank you for having us heathcliff go hacking right there go get them hearts you
Automatic transcript — names and jargon may be misspelled.