Web3 实习计划(冬季):Speedrun Ethereum Basic Workshop

Web3 Internship Program — Winter · 1:12:04

This winter Web3 Internship workshop introduces the Speedrun Ethereum development exercises.

Speakers

Topics

From Web3 Internship Program — Winter, published by ETHPanda and LXDAO; community: ETHPanda.

Transcript

Hi Austin, >> we got we have some great animals on this call. That's very cute. >> Yeah, I'm like a Zoom. >> Okay. Um yeah. Hi everyone. Hi Austin and thanks for joining us today. Yeah, as you all know during this um phase of our website internship boot camp we've been using spir as one of our um core learning resources and materials and today we are very happy to have Austin the initiator of the spironer join us for this workshop and he's also the head of tab

grows at the foundation [clears throat] yeah so without further ado let's give a warm welcome Welcome to Austin and let's get started. >> Awesome. Thank you for having me. Uh I don't have like anything in particular planned. We can go through speedrun Ethereum. It kind of would be nice to know where everybody is at and if people have questions. So maybe I'll pause for a second and let's see. Do we have a chat here? We totally have a chat here.

Let's go to the chat. Uh, how many people have I how many people have uh written a smart contract before? Maybe that's a good place to start. Uh, how many people out there just drop like a thumbs up in the chat or something if you or throw a thumbs up uh in the reactions maybe if you have written smart contracts before. Few people.

Few people. Okay. Okay. A lot of people. A lot of people. Okay. Cool. Uh and then maybe uh how many people have like gone through the challenges? I I didn't fully uh get the full context for this, but how many people have gone through the challenges on speedrun Ethereum before? uh or maybe like how many people have completed the first couple challenges of speedrun Ethereum. Here it is here. Drop a thumbs up in the chat and let me know. And then just so I don't end up covering a bunch of stuff that we already have. It sounds like that's sort of a yes. Let's see.

Just passed challenge zero. Ran into some difficulties. Finished challenge zero and one. Okay. So maybe this is kind of where people are is kind of at the beginning. Uh let's just maybe like quickly one 0 one and two. Okay, cool. So maybe we'll like run quickly through these first few challenges and sort of like what you should be learning by going through them and then we can maybe go a little bit deeper on some of the other ones. Okay. So, first of all, um I kind of I I was just reading the Dex challenge and it it tells you specifically like turn off cursor. I think the time has come that we can use

claude and cursor more often. Uh I don't know if there's restrictions on it there though. How about thumbs up for vibe coders? Are you using claude and cursor to vibe code apps? Anybody out there doing that? Send me a thumbs up if if so or a Yeah. Okay, cool. Okay, so I'm assuming yes. Okay, good. Good. That's good. So, it looks like generally people are doing that either cursor, claw, codec, some kind of AI, LLM, and then uh a code loop.

Uh I've never even heard of anti-gravity before. Cool. Okay. So, that's good. And and I think that like the guys who wrote this uh speedrun Ethereum and I did a lot of early writing of the curriculum, too. I feel like they're they take it a little bit too seriously. And then when you get in here and you look at, let's go look at the decks. One of the most important ones, there's definitely this kind of like turn off your AI because you need to learn how the code works. And I totally agree with that, but I kind of we're getting to the point where I kind of disagree with that now.

[laughter] Like I used to think that you should not have AI and you should really get in and you should learn like each little bit of code, but I think things are moving so quickly now and AI is getting so good that you can probably just tell Claude and Cursor to go build you a DEX. Actually, let me let me go do that real quick. I'm going to tell Let's see. Let me just send that in a a console somewhere. Uh yeah, here. Right.

>> Write this deck for me. >> I just happen to have the Dex challenge up. I'm just going to go ahead and give it uh the Dex challenge. I'm not even going to give it. Yeah. Yeah. Yeah. I'll give it the challenge and I'll give it the the dex.md. Sorry, you can't see my screen. Let me let me share the whole thing uh in a second. But but really, I guess I'm saying all of this to say go ahead and turn on your AI. it's probably time to do more vibe coding stuff and do stuff faster. And so the the way the speedrun was built initially was to go very slow through it and to understand every single line of code. And I just don't think we learn solidity like that anymore. I think it's gotten to the

point now where where we will learn by building a whole bunch of things and trying some things and kind of playing with things in production. and AI has gotten good enough that it can kind of write uh a lot of this for you. So, I would say we're we're kind of changing this and this is kind of in motion right now and the the tides have have changed here and I think that you probably might want to do more vibe coding here. Okay, so back into uh the first challenge. Let me just go look at this thing and see if it's like doing its thing. I guess I have it in plan mode right now. Okay. Uh let's look at tokenization. So tokenization is hot right now. We we hear people even talk about RWAs, right?

RWAS. RWA.xyz. There's a whole website for it, right? There's a lot of token standards and a lot of institutions coming in and tokenizing things. And the way that they end up tokenizing things uh usually has to do with like compliance and other things. But in this challenge, you end up just making an NFT. I think I don't even think it's an ERC20. I think it's an ERC uh 721. So, there's also some links to basics. I if you haven't and it's your first time, I would click through to that link and go watch this other video of me. It's a couple years ago old at this point, but it covers a lot of the the good things.

And then the web two to web 3 kind of teaches you how to set up a wallet. Okay, that's another question. Give me a thumbs up or a yeah in the chat if you have an Ethereum wallet with some ETH in it. Do you have a wallet set up with like a 12-word seed phrase and everything? Oh, yeah. There we go. We got lots of yes. We got some of courses. Okay, great. So, we have holders of ETH. We have builders on ETH. We're we're going through and we're learning. Okay. So, uh in this challenge, uh you you're just making it. I don't think you have to write any code at all. Oh, cool. There's even a punk strategy uh shout out. I haven't seen that that some of these things have been updated.

Yep. So, you basically make this little buffalo, which I have on my hat, by the way. Check out same buffalo. Yeah. Uh you make some buffaloos and you mint them around on Sapolia. And um here's another hot take. I don't think you probably need to use Sapoleia anymore. I think you probably should just put this on an L2. So, uh, even though this tells you to deploy to Sapoleia, I would say you should put it on, uh, base or, uh, arbitum. Let's, let's go look at that real quick, too.

These are super cheap. It's even super cheap to deploy on Ethereum. One time I deployed an NFT contract on Ethereum, and it cost me $1,500. $1,500. That was so dumb that I did that. Now, it's it's super cheap. You can probably deploy an NFT for like two bucks or five bucks or something like that, right? And if you deploy it on an L2 like arbitrum or base or optimism, it's going to cost you like a few pennies. So, uh yeah, with Fusaka. Exactly. Exactly. Nice.

We've got some some fork connoisseurs here, too. That's great. So, uh I guess there's a lot of hot takes here. You should start using AI more than we say here. You should start using real networks rather than using test networks. I think uh it's so cheap, you might as well put it out on uh an L2 and mint some to your friends and they'll have them forever because Yes. test in prod. Exactly. It's it's time to test in prod because these networks are so cheap. Uh, but you'll mint an NFT and you'll send it around and I think you get to you learn about Oh, that's the DEX challenge. Sorry. You get to learn about burner wallets and a few other

things. But this first challenge is basically just kind of cute and kind of getting you set up and getting things ready so you understand. And then the next challenge is a crowdfunding uh app. This used to be called a staking challenge. It was kind of like misnamed because when you really think about staking in Ethereum, it's sort of staking and slashing, which by the way, these cool screens behind me. That's what they're doing. This is uh this is my uh consensus layer and this is my execution layer. And it's running two validators. And if they are off, I start to leak money. I have 32 ETH staked uh for each of these. And if when they're off, I start to lose money. When they're

on, I gain money. And then every once in a while, two two or three times a year, I actually create a block on Ethereum with with these computers here. Uh so if but if I were to bring up these machines and then bring up a second copy of these machines with the same keys, I would get slashed. Or if I mined a block that had something wrong with it, I would get slashed. So, that's staking and slashing. Sorry for all these uh side quests, but this used to be called the staking challenge, but it's really more of a crowdfunding challenge. Yes, validator at home right here. Uh so, crowdfunding,

what you're doing here is you're getting a bunch of people together to buy something to purchase something larger than than you can purchase individually. And uh this is something that a lot of people use Ethereum for. It's a it's a coordination mechanism, right? You're helping people coordinate financially to do something. And this is really starting to where you start to learn some of these concepts in particular. You kind of learn here's the AI thing. I think I think pull it. I think just start using your AI more. What I would even do is I would even like copy this whole thing and paste it into uh chat GPT and be like what are the main lessons to learn here? I know you can't

see it, but I'm just typing it in just to see what what GPT says. Uh I basically just copy pasted it and asked what the main lessons are. I I think this is the way to do it. Like copy paste this whole thing into GPT. You can ask it questions. You can kind of iterate a little bit more. you can get a nice little like outline of how it works. Uh this is not cheating anymore. This is like how you do things and how you learn. Uh you could even uh probably like have it teach you and teach you more things. So don't uh don't listen to this warning. This was like an early warning probably when you know two or three versions of Claude ago, but it's just gotten so much better now.

So in this crowdfunding though, there are some important concepts that you want to learn. And that's what you really want to do is sort of speedrun these concepts. And I think a very important concept that you learn in this challenge has to do with how your smart contract that you're building is kind of like a state machine. And it's in uh at first a deposit state. And you let people put money in. Let's say we're all going to raise enough money to buy uh an island, okay? And it's a million dollar island and we need a thousand of us to each put in $1,000 or something like that, right? Uh if it was just 10 of us and we were collecting $100,000 a piece,

there's probably someone that we could trust, right? Greenland. Nice. Very, very topical. Yes, we're buying We're buying Greenland. Uh, so we, let's say if it was just 10 of us trying to get a million dollars together, we could probably have some kind of escrow, some kind of arbiter, some person that would just handle it for us and we would all send them the money. But once you get to like a thousand people, the trust breaks down. It gets kind of hard to to coordinate. There's lots of different people with lots of different accounts. And how do you track everybody? Maybe it's a database and then what if someone updates the database and you don't trust them?

Eventually, you get to the point where a blockchain starts to make a lot of sense. And and this is where a smart contract is very useful. You can build a smart contract that keeps track of each person depositing their $1,000. And then you can uh have another state that happens at some amount of time, right? So you have some um some timeout or some time at which you want to move from the deposit state to a different state. And this is another kind of aha moment you have as you're going through this challenge. There's no nothing automatic happens on Ethereum. You might think that at a certain amount of time you want something magical to happen

where either people get paid or they don't. But it doesn't happen automatically. someone has to poke it, right? And this is where you start to learn about how uh incentives are very important. In in the case of this challenge, there really is no incentive for the anyone to click the button. Basically, let's say there's a thousand of us and all of us put in our $1,000. You what you need to do is now put it into a different state. You need to either move it into the success state or the failure state. And to do that, someone has to make a transaction against it that says the time is now past whatever time we we programmed in as the threshold. And we have collected

or we haven't collected enough money. And there really is no incentive to do that. So, if you really wanted this thing to be very decentralized, you would say, "We need a th000 people to all put in $1,000 and whoever pushes the button after the time has passed gets like a hundred bucks or something like that. There has to be an incentive built in. And once you do that, once you write all the rules correctly and build an incentive in, then you know that it's going to work because you know someone out there will collect that hundred bucks. You can always count on a human to go try to make money, right? And so if you have

enough humans with enough of the correct incentives, even if half the world falls apart and half the world's machines are down and you know some war is happening over Greenland and all these computers go out, someone out there somewhere still wants to make a hundred bucks and they'll have some script running on some computer somewhere, right? And so that's how you can assure that your state machine will move into that next state is you write the rules correctly saying after this amount of time move to the next state but you also provide that incentive and that's that's like one of the highlevel aha moments that you should have as you go through uh this

crowdfunding challenge is that you're thinking of it like a state machine. Nothing is automatic and you have to poke it. Uh but in this case, there's no there's no incentive to poke it. Someone just has to poke it and you poke it here and we're kind of just like moving on with it. But uh you'll see in later challenges we start to talk about incentives a lot more and we make sure those incentives are aligned. And we'll talk about that in particular when we get to the overcolateralized lending challenge. But just to recap real quick, nothing. It's even saying that I'm looking at my chat GPT window here now.

Uh, and it's it's saying that smart contracts are state machines. Uh, if okay, perfect. Wow, this is really good. So, I pasted it in and it's like saying all the things that I'm like getting up here to say kind of uh at the same time. Ethereum is a coordination machine. It's not a database. It's a coordination machine. Okay? And smart contracts are like state machines. You're moving them from one state to another and nothing happens automatically. And this is extremely important. Someone has to wait for the deadline to pass and then whether the threshold is not or met or not uh depends on the rules but someone has to poke it. Someone has to click the execute button and move it from the

deposit state into either the success state or the failure state. And then a a really important thing here is you need to design for adversarial behavior. You have to imagine that out of these thousand people that we're collecting this money from to go buy this island, some of them are bad people and some of them would actually take all of your money if they had the chance. If they could put in $1,000 and then figure out some trick to get a million dollars out, they absolutely will do that. And you have to assume that there are people like that always out here doing this kind of thing. So just know that adversarial behavior is important and something you need to look out for. And so yes, driven by human nature. Exactly.

Which is a good thing. You can count on people to do what uh what they'll do. I'm kind of moving my screen around here. Anyways, you you want to make it so no one can steal money and everyone can get their money back. If if someone could continue to poke the contract and keep everybody's money locked up, that would be very bad, too, right? So, let's say we didn't get the million dollars together. We only got $900,000. 900 people need to get their $1,000 back, right? So after the time period elapses and it's time to move to the next state and someone pokes the contract and it calculates, oh, we

weren't able to make enough, then it's going to move that state machine into the withdraw phase. It's going to be uh not successful and everyone can get their money back. And that's really important. It's important that either the money goes on to buy the island and everything works successfully or everyone gets their money back and very importantly no one's money gets stolen and no one can grief, right? No one can can lock everyone else's money up. And this is this is a kind of very important concept here and this is kind of what you learn as you go through uh the the the the crowdfunding challenge here.

There's some other things like events in the front end. You can trigger events. Storage is extra expensive in smart contracts and you can trigger events and those events are easy to read in the front end. Um, let's see. Decentralization risk takeaway. Yeah, there's a lot of like slop here in the GPT answer, but still if you just take this thing and copy paste it into GPT, it's going to give you a pretty good highlevel uh uh kind of readout of what you're going to learn from it. And then I would say take another step and have GPT write the smart contract for you. And then if you wanted to go very deep, go in and go

line by line and understand it where you're setting up the deadline here. You're setting the threshold. Uh and then eventually you'll you'll write the the functions that help you decide on which way to go in your state machine. Okay, I'm going to pause there to see if there's any questions and then we'll move on. Sorry if I'm going too slow. Also, someone would give me like a like a yawn emoji if I'm going too slow and we can we can speed it up a little bit. There's really not that many challenges here. And also, if you have questions, please just ask. Throw them in the chat, unmute and ask. Like, I give this talk all the time and it's the same thing all

the time. So, if you want, you can make this choose your own adventure and you can ask questions and I can try to answer them. Really some great stuff in the chat. some good uh Greenland and and uh other things in the chat. So, if you have questions, please ask. But hopefully you're starting to get like this picture of what you might use a blockchain for. There's kind of this coordination mechanism that's this massively multiplayer and trust kind of breaks down. Once you have 10 people, once you have 20 people, once you have 30 people, pretty soon you start to not trust people. and out there at, you know, thousands of people putting in thousands of dollars, you really don't want to have that in a centralized database. And, you know, eventually when

it gets to nation states buying countries and continents and different land masses, then trust has really fully break broken down and you really need a hardened system that that does exactly what it's programmed to do. That's what you get with Ethereum. Okay, let's move on to the token vendor. There's no questions in the chat. Please ask if you have any questions. Uh, the token vendor is going to help you sell a token. Oh, wait, wait. Here we go. Who will execute the process of funding?

Okay, this is kind of something that's glazed over in the crowdfunding. You're right. What needs to happen is we need to be buying that island on chain somehow, right? There needs to be some kind of execution of the money. If we use this like super cool decentralized system to collect a million dollars and then there's like one dude that takes the million dollars, then like there's no point in using a a blockchain, right? Like you should have just had that one dude raise the money in a database somewhere in a spreadsheet, right? So, we're kind of making the assumption that we can maybe buy this uh island as an NFT or it's already sort of like tokenized. So, we Yeah. So, uh yes,

that's a great question. And the question and the the answer is we're kind of glazing over that and assuming that it's kind of uh there's like some system here where the land is actually tokenized and it's already digitized and put on chain and we're buying it out of a smart contract. So there's definitely some other oracle systems that would need to happen here if you're not doing that. And it's all kind of decentralization theater if you're just using the smart contract to collect a bunch of money and then one person. Now, what you could do is you could trust something like a multi-IG, right? You could have a large body of people that you mostly trust and

you could say these 15 people have to all we have to get 10 signatures from 15 from out out of 15 people. 10 people have to sign off on sending the money somewhere and they'll send it to whoever they're buying the island from and we'll basically trust that multi-IG. And there is a multi-IG down at the bottom, but also like a Nosis safe. If you uh who who has a Nosis safe out there, how about that? Any thumbs up for people who are Nosis safe holders? I'm going to drop that in the chat because it's uh a great way to custody your funds. If you have a bunch of money on your cell phone

or in a on a seed phrase that's like, you know, buried in your backyard or something, if you lose that, it could be gone forever. So, a really good way to custody your funds is to have a smart contract wallet like a Nosis Safe and have M out of N signers. So, maybe it's five out of nine signers or maybe it's two out of three signers. And so, if this leaks, you know, someone gets your phone, they can't just take your crypto, right? they have to have your phone and some other device that has a similar or different uh security model. Uh maybe it's three of your friends, right? Maybe

you have five of your friends and your wallet and you have to get three signatures together amongst all of those. So even if two of your friends lose their phones or get robbed, you you need, you know, two or two out of five or three out of five or three out of six, something like that to be able to send that crypto out. And so this is probably the best way to um custody your funds. I was just talking to a bank the other day and the bank was talking about how they want to give exposure to their customers to be able to buy ETH. And so the bank was going to have to hold a bunch of ETH and they were asking me if HSM or MPC I got a

MCP, right? No, MPC. MPC and MCP are two different things. One's AI and one's multi-party computing. Uh multi-party computing is like kind of like this multisig, but it's actually built at the cryp cryptographic level, right? So when he asked me like HSM or MC MPC MPC I said no neither of those you should get a multi-IG you should have multiple people within your organization have multiple wallets and it takes you know it's kind of like one of those like launching the nuke scenarios where you have to have like three people all with different keys turn them at the same exact time to to launch the nukes or

whatever. Same thing. If the bank holds millions and millions of dollars of ETH and they need to send some of that ETH out at the end of the day, they need to collect signatures from a bunch of people and send it out. So, that was a a a long tangent uh to get to the point of saying maybe that's how you would go about buying the island. You would have the crowdfunding, move the money into a multi-IG, and then you would have 10 out of 15 trusted parties all sign off on the money needs to go to this address, and that address represents the seller of the island or something like that.

Hopefully that answers that question. Very long-winded way of answering that question. Okay. Uh token vendor, you're going to sell a token, right? the ICO craze of 2017 where people um sold their tokens in like 15 to 30 seconds and they raised like $20 million. It was it was a wild wild time. Uh but this is how you would do it. you would mint a token and you would have that token set up so you mint it into another smart contract and then that smart contract sells the token and it's really easy. You set up some price

that you want to charge people some tokens per ETH and then someone can come in and call buy tokens and they can send in some ETH and then you send them back some tokens. Uh but there's some interesting concepts you learn here. I think one of them is the fact that when you're sending tokens, you're doing this kind of contract to contract communication, right? There's a smart contract for your token and then there's a smart contract for your vendor and the vendor has owns some tokens. So there's the owner of a bunch of the tokens is

actually the vendor smart contract address, right? The smart contract of the vending machine has an address and it owns most of the tokens and when you put in money to buy it, it goes to the token contract and it says, I want to send some of my tokens to this address. Right? And so kind of weird stuff that happens there. But then if you buy those tokens back, that's when it gets really interesting. if you want to set your vendor contract to buy or sell the tokens. So, you're selling the tokens, that's easy. People put in ETH, they get tokens. Uh but when you buy them back, something far more interesting happens because if you're a third party and you want to send some tokens into a smart

contract and then have it execute some code, you don't just send the tokens in. It's such a weird strange model. What you do is you make a transaction on the token contract and you approve the vendor contract to take the tokens from you. Okay? So the first you you make one transaction to the token saying the vending machine can take my money and then you make another transaction to the vending machine saying take some tokens from me and give me back some ETH. And then the code within the vending machine makes a call to the token contract and says, "Give me some of this user's

tokens." And if that works successfully, then the vending machine knows that it's just collected x amount of tokens from you. And then it sends some ETH to you. So there's this really strange approve pattern and this really kind of like backwards way. You don't just like send some tokens to the machine and it does some things. You approve the machine to take it and then you go poke it and it does some things with it. And so these are these like highlevel concepts that that you need to understand when you get into building on Ethereum just cuz it's kind of some weird stuff you have to do.

It's by far the easiest out of all the blockchain environments to build on. The EVM and building on top of Ethereum just like makes the most conceptual sense. But there's still some very strange things like this approve pattern and you just kind of have to learn these gotchas as you get in here. Another thing that you'll probably learn here is like decimals. Uh there are no decimals here, right? It's everything you do is basically you take it times 10 to the 18. Oh, did someone unmute there? Was there a question?

>> Oh, maybe that was an accident accidental unmute. All good. Uh but but decimals are very interesting here. So if you wanted to say um have 5% of all of the money going in as a token go somewhere else, you don't just take the amount times 0.05 or something like that. That's actually a decimal. What you do is you multiply it times uh 100 and then divide it by 105. So you have to do all this like numerator denominator stuff and then tokens have decimals that are just these arbitrary like we say that most tokens have 18 decimals.

USDC has six decimals. Uh but what that really means is the EVM doesn't want to do floating point math. So it has to do all whole number math. And so there's never any actual decimals. When you put the number into the smart contract, you multiply it times 10 18. So when we say we have one ETH, you actually have 1 * 10 18 way. So that's ETH verse way. And that's another thing uh that you kind of figure out as you get into this.

And you can kind of like look up these uh if we say we have one ether, you have this much way, right? And so this looks like a huge number, but really it's just one ether. And then if you, you know, have 10, then there's just another zero there. And what this allows you to do is there's this arbitrary method of taking this number, multiplying it by 18 zeros, and then doing whatever math you need to do. That's how it stores it. it stores it with all those extra zeros on it and does all the math there. And then when you show it to the user, you just say it's a 10 or maybe it's like 0.001, right? Something like that. The user sees this or maybe even they see this, right? It would be even better if you

could show it in dollars, but it's actually taking this times the price, but really this is the amount that we're storing in the smart contract. So, another weird little gotcha that you kind of learn along the way. These are the concepts you have to pick up to build these things, but you pick these up really quickly and you just get super used to them and then pretty soon you're deploying a bunch of smart contracts and building lots of things, especially with AI and cursor and claude. If you just go to claude, here's here's what you do. You go to scaffold ETH, you open this up, uh you do MPX create latest and you open up cursor and you say build me uh a vending machine contract that sells my

token for a dollar per token or 0001 ETH. Oh, was there a question? I think it was another accidental unmute, but feel free to ask if you have questions or even throw it in the chat. A lot of cute a lot of cute animals out there. [laughter] We got a giraffe. We got fox. Is that a seal? Got some good ones out there. Okay so there's all these concepts in speedrun Ethereum. We've kind of gone through a bunch of them already. state machines and trustlessness and you have to poke

it and decimals. Uh but when you go to build something, cla and cursor is just going to oneshot this stuff for you. But you just need to understand what's going on underneath. And so that's why the speedrun is good. Uh and why I'm kind of urging you to actually kind of ignore the AI thing and go through these for the highle concepts rather than learning the syntax. You don't have to write solidity anymore. You can just grab this. You go to MPX create ETH. You open up Cursor and Claude and you say, "Build me a vending machine contract that sells my token and it will sell your token."

Okay, good, good, good. Yes, I have like a very plain English accent. I think I I was like raised uh in Wyoming, so I have like no accent at all. Okay, cool. Uh let's see. Let's move on to uh the dice game. Okay, we'll just quickly look at this one. This one's kind of fun because you This is your first attacking a contract. You'll actually attack a contract and make money. So, the way that works is there's this contract that has you pay money and then it gets a random number and if your random number is equal to a certain thing, you win some money back and the

odds are about as equal as the uh opportunity. So the way that works, uh, the way you attack that is it's using what's called the previous block hash. So, uh, back over here, if we go look at my validators, each time a block is mined on Ethereum, if we go to Ether Scan and we go look at some block, right? Let's go look at the latest block. There's going to be a wild block hash here somewhere. I don't even know where it is. Maybe it's not here. Here it is.

Here's the block hash. These are basically random. Uh, and back in the day when you had Yeah, random number attack is exactly what we're doing here. Uh, back in the day, you had miners and they were looking for leading zeros here, right? And it was actually the hash of something. So, there wasn't actually leading zeros in this hash, but uh, there was this amount of arbitrary difficulty and you were mining the blocks by doing proof of work. And so this hash ended up being this really nice piece of entropy where it's very random. Okay. And so theness in in a dice game would be they say the previous blocks hash. So that and you

would mod it with something, right? So you would say someone rolls the dice and we'll say the previous blocks hash modded with six. And so it'll be a zero through a five. And if you hit a one, for instance, you win six times your money. So what you can do here is you can attack that. This is meant to illuminate the fact that randomness on chain is kind of tricky. In a public deterministic blockchain, doing randomness is kind of tricky. And what you learn eventually is there's ways like VRF, which is a way to go to chain link and it will give you a randomness or commit reveal. I I would

recommend learning commit reveal if you're making any kind of games or anything like that. Go look up commit reveal. And really, guess what? All you have to do is just tell Claude and Cursor to make one. And you have to worry about a few things like make sure they can't reveal on the same uh block and make sure uh the commit uh the reveal happens with within 255 blocks because you lose your commit. It it can only go back 256 blocks to get that commit hash. So, there's a couple little gotchas, but AI Claude Opus 4.5 will oneshot this. If you say, "Make me

a game where I commit a number and I put in a dollar and then uh I reveal it and you hash my reveal with the with the commit block hash and if it's, you know, a mods to some number, I 10x my money or something like that." This is a good form of randomness and this works. Uh but in in the case of this dice game, you're not doing that. You're actually using uh the previous block hash. So you'll attack that contract. You'll build a contract that will uh only basically only pay to roll the dice if it's going to win. Your contract will be able to look at the previous block hash and then decide if

the module modulo. Oh man, I don't know if I'm saying that right. Uh is is the correct number basically is am I going to win if I roll right now? And if so, then I pay to roll. And so this just illuminates randomness on chain. If you're building a game, look into commit reveal. You can just tell Claude to oneshot you a commit reveal game and it's going to do a pretty good job. Okay, now we're really getting into DeFi. We kind of had a token. We, you know, we we we tokenize something. we can send around those tokens. We created a vending machine. We can buy and sell those tokens. Uh but that's at a certain price. If you want people to be able to exchange tokens uh

at a dynamic price and you need that price to be discovered by lots of people trading against it, uh you you basically had to have an order book system and that order book system was centralized. So the the invention of the decks was very cool. When they invented the decks, they said, "Well, what we need to do is we need to have a whole bunch of reserves of both of these." And if you think of them like scales, uh, like a scale that's kind of weighted, right? If you want to if you want to put a little bit on the scale, it's going to go like this. So, you're going to need to take some off the other side to even it, right? It's called a constant product, I think. And you'll get in, you'll learn the math, go through this one somewhat slowly, and figure out how it works. But

basically, there's a whole bunch of tokens and there's a whole bunch of ETH. And if you want some tokens, you can put in some ETH. And depending on the ratio of the tokens to ETH, you'll get some tokens out. And if you put some tokens in, you'll get some ETH out. And it's all about the ratio of the two assets in the reserves. And the more assets you have, the better the swap, the the better uh the the deal is basically that you get between the two assets, the less slippage there is. And so what you want to do, here's here's where we're starting to get to some interesting smart contract stuff, is you want to incentivize people to LP, to put money into uh this DEX. So what you do is you

build a fee structure. You make sure that the LPS, the liquidity providers, the people who put the reserves in the contract to allow people to swap back and forth, actually earn fees every time someone swaps. So now when I, as a user, go in and I put in some tokens, I'm going to get some ETH back, but it's going to leave just a little tiny bit each time. And so if I were to take $100 and just swap it back and forth all day long, slowly value is going to acrue inside the DEX to the liquidity providers. I'm paying a tiny fee every time I'm

swapping. So I'm slowly losing money if I'm just swapping back and forth and back and forth. And that is to incentivize the liquidity providers to provide that liquidity. And this is another neat thing about a decentralized system. Anyone can provide that liquidity. So you as the the DEX deployer, you just write the rules correctly and you correctly incentivize the right behavior and people will put their money in there to earn fees and then that will allow other people to swap their fees and you've built a beautiful coordination mechanism, right?

And that allows you to have this DEX that's always on, never goes down, no one can censor it, no one can stop it. People can always swap their tokens. And so get in, use this. Uh there's this really nice kind of this is another way to think of it. You put tokens in and you get uh tokens out. Try it out. Play through it. There's some nice visualizations you get here uh as you you put in tokens and you play around with it. >> Yep. Was there a question? Oh, another another unmute. I get so excited when someone's gonna ask a question. Please ask. And you can always just type it in and I can I can respond there. Okay.

>> Last maybe 10. Oh, yep. >> Actually, I can ask a question. But okay, like back to the dice game. >> Okay. Okay. Dice game. Um uh I mean uh if it comes to the computing world uh there always abstract that um the s um the real random or the false random. Uh my question is in the dice game how do you b balance the use of true random versus um pseudo random numbers and when is it necessary to use true num random and when can use pseudo random numbers be used? Um that's my first question and uh uh my second

question is considering the uh decentralized nature of blockchain. How do you ensure the fairness of pseudo random number generation and prevent it from being manipulated or pred um predicted? >> Great questions. Okay, so I feel like uh I'm not a math nerd. There's probably people who understand uh true random and pseudo random a lot better than I do. Uh, but my understanding of it is a computer is basically always going to be making a pseudo random number.

>> Even if it's like down to the microscond, it's still like pseudo random. But here's here's how you do it safely. So let's say we wanted to make a lottery and everyone puts in a dollar >> and they get a random number and if their random number is one out of a thousand then they thousandx. It's going the way that you do it is you use a commit reveal system. And uh commit reveal is a little bit weird. Um but let's let's talk through it and see if we can visualize it. Uh maybe I could even just go to like eth.build real quick and we could do let me go let me go do this. So So uh it's commit reveal

is what it's called. Uh let's see. Let's drop some I haven't used this in forever. Uh, let's see. Text. So, it's called commit reveal. And if you just go look up a commit reveal, you'll kind of probably get a better explanation than I can give. Uh, but what's happening there is each time there's a block mind, uh, there's a block hash. Okay? And that hash we've kind of talked about is has has pretty good entropy because it's the process of hashing all the different transactions together. It's not something that someone can arbitrarily set. Okay? So, you have this nice kind of like good entropy each block, but you can't do previous block hash because you

can game that. And that's how the dice challenge works. It teaches you how to game that block hash. Here's what you do. So, you as the user come up with a pseudo random number. Okay, this is just any number. It it it could just be like five six 28. I'm just like thinking of random numbers here, right? Okay. So, I come up with a random number and then what I do is I hash that. Okay. So, I turn this into a hash of my number. Okay. And then I put that hash on chain here.

Okay. So, my hash gets mined into it gets saved on the blockchain. Okay, no one knows my number because they only know my hash. They can only see my hash, right? And then on the next block or a subsequent block, I turn in what's called my reveal. Okay? And then within the smart contract itself, we hash that reveal and we get that early commitment and we make sure it's equal to that same number we put on chain before. Okay. So now what you've done is you've successfully revealed a pseudo random number that the user

created. Now here's where it gets really tricky. You then take this hash from that previous block that the user didn't know when he created this and you hash that with their secret that they came up with over here and you get a new number that is pretty darn good randomness. Uh it's the hash of two pseudo random numbers that neither party could have guessed. Basically, you'd have to be running a validator and also running this process. So you there's there's like probably some like very edge case scenario where if you were running

enough validators, you could probably figure out a way to like game the system slightly, but you're not going to be able to change this number. So you create this number, you hash it, you put the hashed version on chain, then a new block gets mined, you reveal your random number, and your random number is then hashed with the block hash from the previous block, the commit block, and that gives you this nice random number. And then you do something like the modulus of five, and you have this a nice random uh of five, right? and then someone could 5x their money or something like that. So hopefully that

explains. These are all just pseudo random numbers, but there's this game of commit reveal that you play where you commit a hash and then you prove it later on and then that's hashed with a number that you didn't know and it creates a good enough random number. Um so so I can understand the algorithm or the hash algorithm specifically is um the real secret weapon. It's it's not we we are creating a uh real random number just to use the algorithm.

>> Yep. That's exactly right. >> Thank you. >> Yep. >> My question. >> Yep. >> And if you're making a money game that needs randomness, you'll have to do something like this. You do not want to do something like previous block hash. Okay, cool. There's another question there. When I was deploying challenge zero, there were several options including foundry and hard hat. I chose foundry and I found your contract.soul and the website were crude compared with hard hat. AI told me to write my own. Uh, yes. So, wait, I don't know if I know the question here. I thought the question was going to be hard hat versus foundry.

Did you design it for advanced coders or is it written to be completed? It's definitely written to be completed. These are supposed to be like very easy challenges. Challenge zero, you don't even have to write any code at all. You just deploy the contract. So, I don't know what the answer is to this question. I'm sorry. I think that like Foundry and Hardhat is an interesting question. And basically Foundry does like your testing and solidity and hard hat is maybe slightly friendlier around deployments, but basically all the cracked nerds are using Foundry. Uh but hard hat is still a great option and it has more tests in Typescript and you uh sometimes when you're building a front

end, it's nice to have those TypeScript tests. But at this point, you should be just vioding things. Go to Scaffold ETH. You can pick hard hat or foundry. Run this command. Give cursor the thing that you want to build and it will go build it for you. Okay. Uh let's let's speedrun through some of these final concepts. I think you'll get in there uh and and run these. Uh but the deck is kind of allowing you to trade. There's the LPS. There's the fees that go to the LPS and they earn that and that's an incentive, right? Okay.

uh oracles you'll want to learn about for bringing off-chain information onchain. Uh chain link is a good example of that. But really what I want to look at is this overcolateralized lending. This is probably uh and and you'll get into farther things like stable coins and prediction markets. But really this overcolateralized lending is really this really important concept here. We were talking earlier in the crowdfunding about everyone putting in their thousand dollars and needing to move that state machine from one state to another. In this case, you really, really, really need someone to be incentivized.

Uh because basically what you're creating is a lending platform. You're creating a smart contract that has some tokens in it that you're lending out to people. and they're going to lock up, they're going to overcolateralize that loan. So, if they take out, let's say, I think it's corn is actually what they're going to be borrowing. There's some RWAs there, some tokenized corn, they're going to borrow uh $100 worth of corn, but to do that, they're going to lock up like $150 worth of ETH. Okay? And what that allows you to do is you can give them that corn safely knowing that if

they never come back with that corn, you always have their collateral stored in your protocol. You always have $150 of ETH. And if they want to take their corn and run away and never pay you back, that's fine. You have it. You have their $150. What gets scary there is if the value of the ETH starts to go down, right? Imagine that you have $150 worth of ETH for collateral and someone borrows $100 worth of corn, but all of a sudden the price of ETH goes down 50%. Right? And now that ETH is only worth $75 and they've got $100 worth of your corn.

basically you you've you're in trouble. Your your protocol has lost money. And so you can never allow that to happen. So what you do is you figure out a ratio of the stuff they've borrowed to the stuff they've locked up. And anytime that ratio starts to get close, I think in this case they have it at 120%. You have a function in your smart contract called liquidate. And this liquidation is incredibly important and it's it's very very important that someone calls it. And basically what it does is it takes their collateral and it sells their collateral to cover the corn. So you can always

know that you're going to cover the cost of anything you've lent out because you basically you have LPs, some liquidity providers have provided you with that corn and you're lending it out and you're probably paying some fee to them and you're probably charging a fee for people to borrow it. This is all like extra complicated stuff, but the point is you can't ever let more money go out the door than comes in. And so you need this function, this liquidate function to be called. And so in this case, you can't just count on someone to come hit the button. You can't even run, you could run a whole bunch of nodes all around the world and have them all

watching. Something will go wrong there. Someone will figure out how to shut down your system in some way. They'll borrow a whole bunch of stuff. They'll their their ETH will go way down and they'll end up with more money than they put in. someone will figure out how to attack your system. So what you need is a function that anyone can call and they can liquidate the collateral to cover the costs of anything that is borrowed at some ratio of like 120. And the way you guarantee that someone will call this is you give them 10% of that collateral. Okay? So let's say the price of ETH is at 150. They've borrowed $100 worth of corn. As soon as that ETH gets

down to $120, anyone can liquidate it. And basically, you sell all of that ETH and you get $120 back. You give $10 or something like that to the person who called the function and you cover the rest of your costs, the $100, and then actually there's like a refund that goes to the person. they get back maybe another $10 or $9 or something like that in this case with this math. And all of that is to be safe. If the price goes plummeting down, you need it to be able to have that's why it's 120% and not 100%.

Because if the price is going down quickly, you need that liquidation to happen. You need to be able to sell that asset before it goes below 100%. And so this is a very very important concept. And as you are building things on a blockchain, you need to think about these kinds of things. And if you want money going out, you've got to make sure that money coming in is greater than, right? And so that's where this liquidation is very very important. And that's why I wanted to really hammer this this concept home. So go go go through this uh maybe disregard some of the AI stuff. Copy paste this whole thing into chat GPT and say give me a rundown of what we're building here. Uh

you could open it up in scaffold ETH and say write me a lending contract and it's going to do that. Uh anyone question mark depending on latency. Yes, anyone can call that function. It's a really important thing. The liquidation can be called by anyone as long as the rules are set correctly. If it says the ratio has to be at 120 or lower for that liquidation. So if the price of ETH is at 150 and they've only borrowed 100 and someone tries to call the liquidate function, it's just going to revert.

It's not going to work. It maybe they even burn some gas fees or something, but it just doesn't work until that moment when it gets to 120. And I think depending on latency, I think you mean like it could take time for that liquidation to happen and if the price is crashing, that's why you have that 20% buffer. Okay. Stable coins kind of build off of this. Uh prediction markets are a whole different thing. You kind of deploy two different meme coins with the promise to rug one for the other one.

There's a even like an order book system there. You you're going to use a DEX there. ZK voting, zero knowledge proofs, very very cool math, very cool stuff. You're going to use Noir to write uh basically a hidden vote system. Multi-IGS we talked about. And then an SVG NFT is just like a fun uh NFT. And then there's lots of stuff down here. There's a whole tech tree of things you can build. And there's a capture the flag system that will test uh if you can really like take on some complex solidity. So, all of these things are available. Go take them on. Uh if I don't know if we have a Telegram channel together. Uh let me just drop my Twitter

here and you can ask my Twitter. I'm this guy right here. Let me drop this into the chat. But feel free to follow me on Twitter. My DMs are open if you want to ask questions. Uh but yeah, the speedrun is is fully available. Okay, you talked Here's a question. Hi Austin, you talked about designing for adversarial behavior because code is law. However, in RWA projects, if an attacker exploits the logic to legally steal assets, uh yes, this is very tricky. This this is a a constant question that comes up. If I write my lending platform and maybe I'm off by one on my decimal

of my ratio or something dumb, right? If I do something dumb and I write my code wrong and someone steals money from me, technically the smart contract did exactly what it was supposed to do. But in the world of humans, you know, we think of that as theft. It's illegal to take money from someone. So this really kind of comes down to this like phil philosophical discussion of code is law. There's even I think a Netflix movie called Code is Law that kind of talks about this where basically people are exploiting smart contracts uh and they're stealing money

but they're just using the smart contract exactly like it was written. So I would say, you know, this is a philosophical discussion, but if someone steals money from you, even if it's written, the, you know, the contract is written, I think that's still in the human world considered theft. And so what we see is people steal money from a contract and then they go wash it in a mixer like tornado cash and then they withdraw their money and it's very hard to trace. So yes, in the real world there's you're still probably breaking some laws and you shouldn't be doing that. Uh but in this kind of code is law world, you're following the rules of the smart contract. So it definitely gets

into some interesting um philosophical discussions. So how do we handle uh smart contracts to do legal? Right. Yes. So there's a lot of different uh tokens that have compliance built in KYC uh things like that. So there are different token standards with different compliance built in that uh kind of mimic the real world more. And that's the kind of stuff that banks and institutions want, right? They want you to only be able to move this token around if you've proven that you are a human that lives in this country or something like that. And so it's just a different token standard with with different uh assumptions.

Uh should we always use a multi-IG to provide a human in the loop? Um I mean even those humans could do something bad, right? The best possible smart contract protocol is one where there's a smart contract that's deployed and no one can ever take it down and no one can change it and it does exactly what it's supposed to do forever. Now, of course, in the in the world of writing software, that's a very hard thing to do. But if you [clears throat] you the best smart contract platform doesn't have any way for even a a five out of 10 multi-IG to change it, right? The the only reason

I was saying the multisig is it's a good way to have like some distributed power but it's not fully decentralized. And if you want to build a smart contract platform, the best way you can do it is fully decentralized where the code is there forever. Not even the person who built it can stop it. It's going to do exactly what it's written to do and hopefully you wrote it correctly and you don't like put in some upgrade system or anything like that. So it kind of comes down to what you need. Maybe you need uh you know some kind of compliance where you need a sign off of different organizations to be able to move the token. That's when you probably need a multi-IG. But the best thing is when

it's just a smart contract and it does exactly what it's supposed to do. Okay. Uh three advices for new builders when they get into this area. So my first is to go through speedrun Ethereum. of course, go through all of this and get all these these concepts we've talked through today. You're not going to get these from chat GPT. If you go to ChatGpt and you say, "Teach me how to build on Ethereum." It's going to tell you about the tools. It's going to tell you to maybe go study some protocols, which is my second piece of advice here.

Once you've gotten good, go look at things like Open Zeppelin. Uh, let me drop these contracts in here. Here are a ton of really interesting smart contracts. Go look at the sole lady contracts. Let me go see if I can find them. Go look at unis swap. Sol I think is what it's called. Yeah, here we go. A homie vectorized. So go look at existing smart contracts. So So first thing go through speedrun Ethereum. Make sure you understand all those concepts that we've talked through today.

Then go look at a bunch of contracts that already exist uh and and learn more about how they work. Go look at protocols uh like unis swap v2 router, right? How does the v2 router work? What you can do is you can go look at it, right? You can go find it on Ethereum mainet. Uh here here it is. I'll just paste it in here. And you can actually just click on the contract and you can go look at the code and see how it works. Right? So go look at a bunch of different protocols and see how they work. And then my third piece of advice is go build a bunch of things. Use scaffold ETH and AI and cursor. It's it's AI ready. It's cursor ready. Follow

these instructions and tell it to go build some things and quit using test nets. Go put go deploy a token on base and send it to your friends. go take some of that token and put it into a liquidity pool on Uniswap and all of a sudden now your token has value and try buying and selling that token and see how that value changes. There's there's so many fun things you can do when you're programming money that just like go try them. Go build a few things. So to recap, speedrun Ethereum to get all the concepts.

Go look at a ton of different protocols and already written smart contracts and then go try to build a bunch of things yourself. Uh I think if you wanted to go even deeper, check out Rare Skills. I will drop this in here. It's all free and they have tons of different um very highly technical topics and concepts to learn. Uh, and then it's kind of a cess poolool. Crypto itself is just a gross kind of place. But go look on crypto Twitter. Crypto Twitter is full of people building and tweeting and trying things. Follow a bunch of people on Twitter and follow the things that they're interested in and pay attention to the meta.

Uh right now a big thing in the meta is ERC80004 and uh X42 for payments. These things are really neat and if you look into them you can see how these like AI agents are doing all this like economy on chain and payments on chain. So and the reason why I found these things is by paying attention to crypto Twitter. Uh probably last question I got to get going. Uh, how do you foresee the evolution of the industry over the next 5 years? Uh, so first of all, I'm not very smart. Like I, if I was better at predicting the future, my entire net worth would not be these two computers

right here. So, first of all, I'm not a smart man. I don't I don't know what the future uh entails. But I think we've seen AI and Agentic, right? There's going to be an agentic economy. AI is going to be huge. people are going to be building and shipping things very quickly. I think we're going to see uh institutional adoption. Hopefully, if we think of, you know, Google having their own blockchain and Microsoft having their own blockchain, neither of them are going to want to use their own blockchain, they're going to need a uh fully decentralized, disinterested blockchain that does exactly what it's supposed to do and isn't captured by anyone. So I think that eventually we

will have nation states settling on chain uh and using blockchains for this as like a you know a third party intermediary. Uh quantum resistance is huge right eventually we need to worry about quantum uh computing breaking some of the assumptions that we have with ECDSA key pairs and hashes. Uh so I think quantum resistance is coming right agentic economies are coming. Everyone's going to be building apps. Institutions are going to be coming on chain. Uh people will continue to grift and try to sell things and make money. So that's always going to be there and it's always

going to be kind of gross. Uh, but there's this really neat thing when we were talking about a smart contract that not even you can stop that does exactly what it's supposed to do forever, right? Ethereum will continue to have 100% uptime. It will never go down. It will do exactly what it's supposed to do. That's a really neat technology and a really cool area to deploy things on. And there's this agentic economy where we're going to have all these agents that don't know how to trust each other, that don't know how to discover each other, that don't know how to pay each other. And Ethereum and Ethereum L2s will be used really useful for that.

Okay, hopefully that's all. If you have more questions, uh, find me on Twitter. I'm this dude right here, uh, Austin Griffith. I'll paste it in one more time, but feel free to send me messages and hit me up if you have any questions. Uh, yeah. Final advice, go speedrun Ethereum. Uh, go use scaffold ETH and cursor and cloud code and go build a bunch of things. All right, thank you for having me. Good luck on the speedrun. >> Uh, hit me up with more questions on Twitter.

Yeah, once again a huge thank you to Austin joining us today and for ongoing updates and any source on develop growth and also about the speed on Instagram. Feel free to follow Austin on X. Yeah. And we also want to thank everyone to participate and asking the great questions. Yes. Yeah. That's all for today and thanks again and um yeah have a good time. Thank you Austin. Thank you guys. >> Thank you. Hearts, hearts, hearts. See you. Go build on Ethereum.

>> Yeah. Thank you. Bye-bye, guys.