Scaffold-Eth is a development framework that enables developers to build applications on Ethereum by providing an integrated environment with ethers.js, Hardhat, and React. It allows developers to write smart contracts in Solidity, deploy them to a local blockchain, and have the front-end automatically adapt to changes in the contract. This hands-on approach helps developers learn Solidity fundamentals including data types, mappings, structs, modifiers, events, and inheritance patterns while building practical applications like vending machines and token systems.
Ethereum Development Guide: Scaffold-ETH and Solidity Fundamentals
Added:hi i'm austin griffith i want to show you scaffolding it's a good way to build applications on top of ethereum it starts with an example smart contract and when you make a change you add something in the smart contract auto adapts if i remove this owner and i hit save and i deploy we're going to see that owner disappear from the front end so it allows you to edit your smart contract try something new and then deploy it to [Music] your local chain and then you have your local app auto adapts to that and we can grab some funds from the faucet and we can poke at this contract but this is scaffolded it allows you to work on a smart contract tinker with solidity learn solidity and also build this this app in the front end it's it's automatically adapting to what you change in your smart contract and it helps you create a front end so whenever you add a new function there's a new button that represents that and you can play with your solidity and learn kind of as you go so that's scaffold ethan i'm going to spend most of my time talking about that but i want to zoom out a little bit if if you're getting into ethereum the best place to start is to go to ethereum.org ether scan is cool too but if you go to ethereum.org this is a great place to to learn about ethereum you want to get a wallet you want to learn where to get eath you'll probably get a meta mask and then with that metamask you can interact with apps then then learn learn learn what eath is learn why we're decentralizing learn why decentralized finance is important endows and decentralized governance and nfts in the history of ethereum and eth 2.0 and here's my staking node right here my e2 node you learn about all that stuff and where we're going and then it's time to develop it's time to build so i i would start with learn by coding you can pick up remix and you can write a smart contract right in the browser or you can use eth build and each build is one that i've put together to help you with the fundamentals just understanding what's a hash function what's what's a key pair what can you use a key pair for how does it sign and recover messages and then on and on to through through encryption and distributed ledger and byzantine general and then eventually blockchain and smart contracts you'll you'll get to all that but what you can do is you can get in here and you can tinker and you can kind of figure out how things work here we have a key pair and i'm clicking this button and i'm generating a brand new private key which derives a public address and we can use that private key to sign you know some some message whoops deleted it hello world so we can use that private key to sign a message and then that message and that signature can go across the network and then if you hook up that message and that signature to a recover box you can recover basically the address that signed the message notice how these two addresses are the same and this goes across the network so that's a super power of these key pairs and this is a lot what allows all this to work and it's ecdsa is what it's called ec dsa you can you can learn some more about the curve and elliptic curve cryptography that's way over my head i'm just a builder uh but eth build will help you get started and poke around and learn some of the fundamentals then you can bring in blockchain and you can do a lot more let's see what the current block number is on ethereum whoops it's not to gray it's right there there there's the current block of ethereum so so that's what you can use uh eath build for and eventually you can you know talk to smart contracts you bring in the address and abi and then you get an interface and there's a lot of uh things to learn from down here in the drawer uh let's just get into like a really big one let's look at the byzantine general whoops not that one there's there's videos that go along with all of these but if i load this up here's all of these soldiers and they're showing how proof of work works we can see this soldier in here jamming away at a hash and then if we look out here all of these soldiers are doing that trying to find a hash with leading zeroes that hashes general bob's message so he can send it out to say he wants to attack monday at dawn so that's kind of an exploration of proof of work eth build is a good way for you to kind of learn about key pairs learn about uh just some of the fundamentals once you've got the fundamentals down you're ready to set up your local environment and there's a lot of great tools to set up your local environment but the one i'll be talking about today is scaffold eath it's it's ethers.js which is probably here too it's ethers js plus hard hat plus react so it's kind of everything working together at once when when it's it's really complicated to build a stack in web 3 and build on top of ethereum there's a lot of tools and there's a lot of things that can go wrong with scaffold eth we we start with something that works we have a back end which is basically our uh hard hat block chain and we have a front end which is our react and we're using hard hat to compile and deploy and then we use our front end to poke at that contract and interface with it so this gives you a full dap template out of the box and it helps you learn solidity and then it helps you kind of build a bunch of different things to kind of learn the tour of duty learn learn the the learn all about uh all the different things you can build on ethereum and what works and what doesn't and some of the gotchas okay let's let's go ahead and dive into scaffold eats some more and let's write just a little code to kind of get you familiar with how to use the tool so let's say we're going through this documentation and we look at primitives and data types and uh oh whoops that's not what i meant to do i wanted to click that we can see if you're a good programmer if you're a good web 2 programmer you should be able to get right in and understand this so we have unsigned integers that with 8 bits or we have an unsigned integer with 256 bits we have addresses we have bools uh let's just let's just grab one of those here let's just grab this address and bring it in we kind of had one here earlier and let's go ahead and copy my address from the front end now if i save that and i deploy it we should see that a new address is added over here over on the right here there we go so now now that's that's the address and let's instead of calling it address let's call it owner and then let's write our first rule so solidity requires uh it uses this phrase require and it's like assert it's checking a condition so if you require that the message.sender equals equals owner and what that's saying is whoever gets in here the message.sender is the person calling this functions whoever gets in here and or or the last person it can be a chain where you talk to a smart contract and a smart contract talks to that's too complicated it's the person who's calling the function and so we're what we're checking right here is we want we want only the owner to be able to get in here and set the purpose and if you're not the owner we'll say not the owner okay and we'll add our semicolon there and we'll yarn deploy i can make this a little bit bigger to make that look a little nicer there we go so we deployed our new contract uh we're building unstoppable let's say apps again i like that better and let's save that and deploy it just so it looks nice oops there we go okay what we've what we have is an owner that can update this storage location so we have this string purpose and we have this function that lets us update that purpose and then we've added this new owner and we said only the owner can set the purpose so over here i should be able to say hello and if i hit send sure enough the purpose updates now what we need to do is test the other case right test the bad guy right we want to see someone else come in so what i'll do is i'll create a new incognito window and i'll go to localhost and you'll notice that i have a different address in the top right see how this one is kind of green and pink and this one is kind of like a purple and green they're they're they're they're a little different right we'll call this pink guy and this purple guy so we'll go to the pink one and he goes and he grabs some money from the faucet and then he trying this and it should fail right it should say not the owner there we go so we've tested this line of code we've we've tried it from someone else and they're not able to set the purpose and we've tried it from our account and he is able to set the purpose so so this line is working pretty well and it's keeping out other people and that's pretty good what we've built here is sort of like a an attestation smart contract where one person whoever controls the private key that goes to this address they're allowed to get in here and update this purpose well that's not that interesting let's think what we can do to make this more multiplayer let's think of this more like a vending machine that anyone can get to so instead of having it set up so one owner can get in there let's set it up so it's payable okay and then what we'll do is we'll say message.value needs to be greater than or equal to 0.001 ether okay and we'll say not enough okay so we've changed the rules around this address isn't important anymore we don't need an owner anymore it's it's not owned by anyone in fact when we deploy this smart contract if we do it correctly not even we can stop it no one's going to be able to stop this vending machine it's an unstoppable vending machine that lets anybody get in here and pay.001 ether if they want to update this string that's a pretty cool pretty cool little build okay let's see let's go ahead and deploy this and see if i've done anything wrong here see if it's happy there we go compo compile deploy and now our frontend updates and there's a new field here to to put in the transaction value so i'll say hello world and i'll do 0.001 ether and we take that ether to whey by multiplying by ten times time we multiply by 10 to the 18 because these these ethereum nodes they run an evm and the evm needs to be simple so it doesn't want to do floating point math so instead of having decimals built into the evm we basically multiply everything by 10 to the 18 to kind of create a a fake decimal system sort of right so 1 eth equals 10 to the 18 way right so when i want to go.001 eth i need to do this 10 to the 18 to take it to and so this value right here is the same as this value right here see that that's the same but it's easier for humans to read a decimal but the machines need it in whole numbers there we go we pay we we call this function which crafts a transaction and it pays to update the purpose so we pay money to update the purpose we pay this much eath and you can see now the contract has money in it so the vending machine is starting to collect value as people set the purpose okay well wait a minute we don't have a way to withdraw that money right and and anyways i kind of want to i want to um show off the superpower of ethereum is that you can innovate on top of this blockchain so if you imagine let's let's back up a little bit and when someone says what does a blockchain look like right what what does a blockchain look like well most people would say it probably looks like a set of blocks in a row right they probably would say that a blockchain looks like this right and it's like these chain of blocks and it's pointing to the previous one well that's that's true right but actually uh if if you want to think about what it physically looks like it's all of these nodes right it's all these nodes on the network so blockchain looks more like this than anything where it's a peer-to-peer network and all these machines are communicating peer-to-peer and they're coming to a consensus about what uh let's think of a distributed ledger first so bitcoin comes to the consensus of what a distributed ledger uh values are alice sends one to bob bob sends two to charlie everyone on the ledger is keeping track of it and everyone's agreeing with ethereum that that ledger it's not just a ledger right where we're keeping track of to and from it's it's it's actually an execution environment so it's a small little computer and everyone runs that small little computer that is the that's not a very good drawing but imagine this this is a little computer and and everyone is running their own little computer and when you deploy this smart contract every node on the network gets a copy of your smart contract and whenever you want to call a function that updates it when we call this update string every node on the network has to update their string to the new value and so this this uh uh distributed ledger that we're keeping track of is actually an execution environment and it's executing transactions and everyone is keeping track of this chain of blocks that kind of secures it with with proof of work so so it's very if if we want to think about ethereum from a web 2 perspective we can think of it like a database where when you have a database and you have lots of people hitting it you need to scale up and you need to add more redundancy well with ethereum every single node is the redundancy so part of the network can fall apart and you can still ask any of the these other nodes that are still here what the value is so it has censorship resistance then then there's this trustlessness where the only thing you have to trust is the code we we know that this is gonna do exactly what we program it to do when i when i said that when we deploy this not even we can stop it that's exactly how you want it to work you want to be able to deploy a smart contract that does exactly what it's supposed to do okay so zoom zooming back in on scaffold eth and building on ethereum we we've built ourselves a a little vending machine here and it has some money in it we need to probably withdraw those funds uh we need to think of it like adversarially though can anyone attack this is there anything wrong with this is there anything we could maybe add to this to show off how we can program that top layer so thinking of that that blockchain right that big network of all those machines they take care of the blockchain stuff for us it's our job to just write our little rules in here and we can innovate quickly by writing little rules in here so let's see what what could we innovate on let's do something else let's do a unit 256 public price so i'm going to keep track of a great big number and i'm going to set it and i'm going to call it the price and i'm going to set it equal to 0.001 ether and i'm going to replace this here basically just set a variable to what we want the price to be and if i if i deploy that it should work fine we shouldn't get any problems i should be able to go back over here hello world and i should be able to send that same exact transaction send some money in and set the price so that's cool let's think a little bit more about economics let's think about how we want to create some mechanism design here and let's think what if we do something like this okay so the innovation we're going to add here is we're going to say the price equals price times 1001 divided by 1000. what that what that's going to do is is slowly increase the price okay so then let's go make sure we get the order of operations correct there we go so we make sure we take remember no decimals these are all whole numbers so we want to do this first before we do that okay i think this is going to work let's go ahead and yarn deploy this and see how it looks what we're doing is we're at we're adding innovative mechanics on top of a smart contract by just adding one or two lines of code and all of a sudden that whole system is going to work a little differently okay so the first transaction i'm going to send but now look at this the price has gone up okay so the next if i say hello world 2 and i send this oh look at that the price is going up a little bit each time i create a new one and you can see there's more and more money going into the smart contract so just quickly we just came up with let's make a price function and then let's make the price go up on a curve we just threw it into the contract we tested it a little bit in scaffolding and basically we're ready we've got this app ready to go we would eventually probably build out some example ui and we'd make it a little cleaner we wouldn't have them do this right we would have that built into the ui so it does that behind the scenes uh but this is built for developers this is ready to go this is this is built for developers to work on their smart contract and learn solidity it's it's you'll want to carve this out and actually build your own front end as you go but a lot of it's going to be right here and the example ui gets you really close to having it and listening to events and lots of other stuff okay so you've got it let's say you've got scaffolding figured out you've built something you're ready to deploy it you'll go to the hard hat configuration and you'll chan you'll choose your network you want to go to mainnet let's send this thing to mainnet you want to go to a test net but send this thing to a test net so you can pick your public network you can uh yarn generate to create a new account then you fund that account and then you yarn deploy and instead of deploying to localhost it's going to deploy to whatever network you want to go to and then you make one other change you go to your front end and you go to your app.jsx and you'll update this network right here to mainnet or whatever you want and it's going to work on that network and then you can yarn build and yarn s3 or yarn surge or send that basically build your static website that's pointed to your contract that's already out on a public network you'll put your your app out on a public network too so then you can basically give someone a url and they can interact with your smart contract app okay cool so that's how you would deploy an app uh once you've got scaffold eth down and and you've experimented and you've learned uh all of these different things to learn right you need to learn primitives and data types you need to learn mappings and what you do by that is you'll click on a mapping you go into here you'll find a mapping and you'll be bring it into your smart contract and you'll say well what does this look like what does this mapping do it's it's a mapping from an address to a uint okay so what it is is basically think of it like balance right it can give you the balance of any given person so if we put our owner in there and we set the balance of the owner equal to a hundred and we deploy this now we've just created a totally different thing this is actually very similar to a token like an erc20 token we we've set it up so we keep track of balances right okay so what does a token need next well probably needs some function called transfer right and that transfer function will take some address to right who we're sending it to and some uint256 amount right we'll make that public and then what are our rules what rules should we set right we need to make a rule right let's require let's require that the balance of the message.sender is greater than or equal to the amount so basically they're they're they're wanting to send some amount we need to make sure they have that amount and we'll just say not enough if if not right okay and then once we know that they have that amount what do we do well we'll take their balance and we'll say that minus equals the amount and then we'll take the balance of the two address and we'll say that plus equals the amount and you just built yourself a token right something something that took a a crazy amount of work five or ten years ago building a decentralized currency you can build in a few lines of ethereum let me hit save and let me deploy this let's see if it worked and and we're this is a hundred way by the way like if i wanted to be very specific that's 100 way not 100 ether so just watch out for that but we're just dealing with whey right now and that's fine i'm just showing how we can see a balance of a person we could uh bring up an incognito person and we'll send them some tokens okay so we'll copy this address and we'll find our transfer function we'll paste it in and notice how it has a nice little blocky preview there that's what scaffold ease does it has a lot of components and hooks that you'll use and let's just go ahead and send them 50 and there we go we sent 50. so now if i check this guy's balance he has 50. and if we go check this guy's balance he's got 52. so it worked and that's that's a mapping that's how you learn what a mapping is you you kind of look at these examples you paste them into scaffold eath and you tinker around with how these work so uh that's a mapping uh the next thing the next thing you'll want to learn are our structs right and that's a struct of primitive data types maybe make a to-do list add things and remove things from the to-do list then you'll learn modifiers it's a way to write those rules in a way where you can have just one rule and then you can apply it to other functions and not have to rewrite those require statements events events are really important because they give you information to your front end the smart contracts can emit events and you can read events from the blockchain so events are stored on the blockchain but they're not stored in a way where other contracts can talk to them so the gotcha with events is they're only for your front end they're only for humans to read they're not for other smart contracts to react to within their logic so the gotcha there is events are great for getting information out but they're not good for using smart contracts to talk to them inheritance is really important so once you once you see that ownership pattern that we set up earlier where only the owner could do something what you want to do instead of writing it yourself you'll probably want to go to open zeppelin and just bring in their ownable pattern and you say this is ownable and now we can go down here and we can say only owner right and now only the owner can get in and i didn't spell it right let's spell it right only the owner can get in there and call that function and instead of having to keep track of an owner and and set up the modifier and set up all that work set up the require function we can just bring in uh open zeppelin's code and so you can bring in a lot of other tokens and a lot of other things from open zeppelin so check that out once you've got inheritance check out the payable and the fallback function uh and then you're ready to start in on the challenges there's a whole ethereum speed run this is this is just learning the language you've just learned the language you've just learned the global units you've learned kind of what what message.sender and messagedup value and block.timestamp is you kind of get it you're a programmer and you understand enough solidity to be dangerous what should we build that's what this is for so here is the eth dev speed run so i i found kind of through teaching people how to build on aetherium there's a bunch of concepts that you need to go through to under to really understand why ethereum works the way it does what works on it what doesn't and it all starts with tinkering with solidity we've already talked about that going through those original uh concepts and then check out the simple nft example basically it'll just walk you through minting your own nft and if you want to get in there and make some small changes to that contract here's your nft contract right here very simple it comes it brings a lot of stuff from open zeppelin then extend that branch to a buyer mint set it up so instead of the artist paying for the nfts set it up so only the buyer has to pay for the gas or the buyer pays for the gas for the nft not the not the artist and it's just a small change that you make but then there's a gallery where people can get in and mint those nfts and then from there you're off to the races there's a decentralized staking challenge you'll learn payable functions you'll learn block time so is it after this certain time then let's execute something else you'll you'll move on to the token vendor and challenge two where you'll learn how to deploy a token you'll learn how to deploy a token vendor you'll you'll buy tokens from your vendor and then the hard part you'll have to sell your tokens back to the vendor and this is complicated because the approved pattern in erc20 it's actually two transactions one to the token contract to approve and then another transaction to the vendor to have it go grab your tokens and then uh give you back ether or whatever play with commit reveal randomness is really hard on a public deterministic blockchain learn why that is learn what commit reveal is learn learn how you can use an oracle to provide randomness and then learn more about oracle's learn how you can bring in feeds from from an api into your blockchain and the pros and cons of doing so something like that learn how to build a decentralized exchange so instead of an order book that could get hacked or fall over you you can actually exchange tokens for eth in a smart contract and the trick there is you hold reserves of each and you trade between the two get into that learn how to build your own decks uh then then there's a lot of d5 stuff learning uh bonding curves for erc20s learning how to build your own swap in the front end learning how to build your own lending functions uh and then ape into learning learning learn how to leverage up with a smart contract and then sign messages are big going back to that key pair where we could sign and recover messages you can do that off chain in something like a state channel but you can also do that on chain like a smart contract wallet can require signatures from a handful of different signers and you can get all those signatures together off chain and make one transaction on chain uh there's there's the ecdsa library there's meta transactions uh and then uh the the final kind of the final boss to beat on the ethereum speed run is to build your own signature based multisig and i have an example here but it's best to build it yourself so check out solidity by example and there's a lot of great examples here including the hacks learn how reentrancy works learn learn how some of these hacks work look at uh look at audits and look at how auditors have have given feedback on other smart contracts get in here with scaffold eth and build a bunch of things follow this speed run get into the chat i'm at austin griffith on twitter let's see right here i'm at austin griffith on twitter reach out my dms are open uh again check out scaffolding this is the place to start right here if you want to get the fundamentals go to ethe.build but once you have the fundamentals jump into scaffold eath and check it out good luck build something awesome on ethereum have a good day bye bye bye
Up Next

Blockchain Bridges & Cross-Chain Messaging Protocols Explained
@ciaranightingale
997 views•2025-02-09

Torrent File Format & Bencoding: A Technical Deep Dive
@AsliEngineering
12.5K views•2022-08-08

Operational Security Essentials: A Guide for Hacktivists (OPSEC)
@hitbsecconf
157.4K views•2012-11-26

Understanding Ethereum: A Comprehensive Beginner's Overview
@99Bitcoins
3.1M views•2018-06-26
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Blockchain & Crypto









































![WOW!! ETHEREUM MASSIVELY UNDERVALUED IN 2020 - [My Prediction]](https://i.ytimg.com/vi/7HM310ygCgs/maxresdefault.jpg)


