[Music] Uh we just finished the first section which was deploying your first app. We uh went through scaffold ETH. We went through kind of the build guild and uh building with scaffold ETH and speedrun Ethereum. Uh now, uh this is what was what we ended up with was our counter. Uh yeah, how's it going?
Cheers. Uh okay, so we ended up with this cool little county counter. Uh this is what it looks like on local host. We were able to build a simple smart contract that uh did kept track of account and then uh a simple front end. We use cursor to deploy the front end and there it is.
we can increment our counter. So the last little piece to do if you're deploying any app will be to put it out on a chain uh like arbitrum. So I'm going to do yarn deploy-work arbitrum and that's going to tell me something like I need to generate a key store. So I'm going to create a new one. I'm going to enter a bad password.
Oh no, that's a key store. Oh, that's the name of the key store. I want to generate one. I I don't know. I don't know which key store I use.
Basically, it does this thing where it encode encrypts local passwords. Let's see. I bet it's that. Oh no. What What am I sitting here doing?
Okay, there we go. Okay, so we're going to deploy this on arbitrum. It looks like it's deploying now. There we go. So, I was able to deploy our counter app to Arbitum.
It's just a simple county counter that probably cost me like a fraction of a cent to deploy. Okay. Now, you need to make one change like after you've been working on local host, you've got your front end, you've got your smart contract, you've looped that a while and worked on it. Uh once you have this and you deploy it to Arbitum or some other live network, you need to get into your scaffold config and tell it to point the front end at Arbitrum. There we go.
No, not Sapoleia. We're going live. Quit using test networks. That's my hot take. Don't use test nets anymore.
Test nets are worthless. The infrastructure is terrible. Just deploy to like an L2. It costs a fraction of a cent. Cost a fraction of a cent to use it.
I made a thousand transactions on arbitrum the other day in like the matter of a minute or two and it cost me a$180. So don't worry about paying finding a faucet for a test net anymore. Just start using L2s. Okay. So now with this one change where we changed our chain on scaffold ETH it was if you look over here right now it's connected uh it oh wait we want to use burner wallets too.
Let me do one more thing so I have a burner No. I don't need burner wallets. Let's just go let's go live. Okay. So now uh our app is on arbitum and there is the live contract that we've deployed to arbitrum.
There is our car contract on Arbiscan. We still need to verify it. Uh but let's connect my wallet and let's go uh let's go let's go increment our counter on chain. That's actually like pay pay money, pay real money to increment our counter on arbitrum. Okay, here we go.
Here is county counter on arbitum. I'm going to click the button and pay real money to increment a counter to from zero to one. Hooray. Okay, so very simple code here. Of course, these are just starter apps.
Uh we're going to dive into the speedrun now and cover uh a much deeper set of concepts. Uh, I'm gonna kind of like gloss over a bunch of builds and then we're gonna have Kevin and Shiv get up here and actually deep dive on the stable coin and then the prediction market. So, I'm going to speedrun like the first six challenges here. We won't actually write code. Uh, we'll now that we've seen how to like deploy an app.
Oh, wait. Let's put let's put it out on IPFS too, right? Once we've seen we've basically seen how to deploy the smart contract. That little IPFS thing is going to put our front end out there. So now that we've seen how to deploy a single small app using Scaffold ETH, what kinds of things do you build?
Now that you know how to build an app, what kinds of things like what do we build? Right? And that's where we move over to speedrun Ethereum. So speedrun Ethereum has a ton of builds. And this is what you need to do as as you become more well-versed in building with solidity.
You're going to get to the point where you're like, "Okay, I know how to build smart contracts. I can do it. what do I do now? And the thing that you need to do is build a whole bunch of things. You need to build a whole bunch of things and you need to put them on a real network and you need to try using them.
And then you need to get to the point where you're building your eighth and your ninth and your 10th thing and you're starting to get users who actually try your app. The goal should be build something that someone's going to use, right? The goal of all of this is building something onchain that is decentralized, that lives forever, that's tamperproof, that other people will use. Okay? So, what kinds of things are people using?
Let's start from the top and come back the other way, right? ZK voting, prediction market, stable coins, overcolateralized lending, uh a DEX, a dice game, a token vendor, a staking app, NFTts. Let's let's speedrun those now. Okay. So, what people use smart contracts for a lot, uh, one of the most simple things is just like a canonical record, like a place where you can go to get information.
Maybe it's just like a hash of a repo. Uh we were just talking about releasing software packages. Ethereum is a great way to track software releases. If you wanted to have like a git release and a hash for the for a certain package, you could totally use Ethereum for that. create a smart contract where a multi-IG or some wallet can sign a GitH users when they go to pull down your code, they just have an extra verification step where they go read from Ethereum what is the hash of this package and compare it to the hash that they have and make sure that they're getting the right code when they download it.
Right? So just creating a canonical record. Uh attestations are another big thing just like using ECDSA key pairs to sign some information and attest to something and then you have some aggregated attestations that come together to give you reputation and information about people or something. Uh and uh then the other thing is like credentials right and that's where this NFT challenge starts is you can build credentials with non-f fungeible tokens. You can create a token that says Kevin owns token one, Shiv owns token two.
Uh that you know Shiv sends token two to Charlie or whatever. So another really good use case of uh Ethereum is creating credentiing and then like token gating or using those credentials for reputation. And you'll do that in this first challenge is you'll deploy these little buffalo credentials and we're kind of changing it up. NFTs are a little bit of a bad word these days. the the the NFT craze is behind us and so is my net worth.
Uh but we've kind of moved on from NFTTS. So I I like to call them credentials now. But uh moving on, I think one of the most important challenges of speedrun Ethereum is this staking app. Basically what you're trying to do is get it's a massive multiplayer game of people who don't trust each other and you're trying to get them together to coordinate. And if you can imagine if we had to get everybody in this room together to go buy a car, we could all chip in the money and maybe you could trust me and I could go buy the car, right?
So when you have that central point of trust, it works for a small amount of people. It it works at a small scale. But at some scale, at some point trust breaks down. And that's the point of Ethereum is it's meant to be trustless. It's a a platform where code runs exactly how code is written and you only have to trust the economic uh the cryptoeconomic system will will hold up.
And we went and looked at that we contract earlier with $9.5 billion in it. There's a lot of bounties to to break this uh system and it still works. It's actually been up for 10 years uh without any downtime. So when you deploy an app here, uh it'll always be up and anyone can get to it and the code will never change and it will always execute exactly how you built it.
So this staking app is to get a bunch of people to coordinate together to purchase something. And in in this case, uh it works kind of like a state machine. When you're building your first contracts, you sort of realize that it's kind of like building a state machine. You have this deposit state that we're in at first where we're allowing anybody to deposit funds into our contract and then Oh. Oh no, that's not good.
Let's get on the Wi-Fi. Oh no, the Wi-Fi is down. I might have to tether to my phone. Uh, let's go back. Can I have that?
Okay, just stay there. Don't click anything. Uh, this staking app means that we want to get a bunch of people to coordinate together that don't trust each other. So, at some point this trust breaks down. Let's say massive multiplayer.
We're trying to get not just the room full of people together to buy a car, but we're trying to get, you know, a million people together to buy a country or an island, right? If we were trying to get a million people together to buy an island and we're all pirates that don't trust each other, we need some system of trust between us, right? And and there's always like an escrow idea where like maybe we trust some third party, but let's pretend like we don't trust anyone. We're pirates, right? And we want to buy an island.
How how would a a a million pirates buy an island? Well, they would probably use Ethereum. They would use some kind of decentralized system where it's trustless and there's just a smart contract. And the smart contract is this state machine. It has this deposit function and it says, "Hey, every pirate in in this in this group, in this DAO, whatever we are, the pirate DAO, you all need to deposit some amount of money, right?
Let's say every pirate has to deposit uh $10,000 and we're going to go buy this island." So, every pirate needs to deposit their money and we write the smart contract that says any pirate can deposit it. And then at some point you have to poke it and move it into the either the withdraw state or the success state. So the state machine needs to transfer from deposit to either withdraw or success. And uh nothing is automatic, right?
When you think of Dows and decentralized autonomous organizations, it almost sounds like something is automatic there. But nothing is automatic on chain. Everything has to happen with a transaction. uh to make something automatic though this is really interesting. uh you think of maybe like running a cron job on a machine, right?
You have some server, the server runs some cron job every night or maybe we set up this staking app and then at night or at the end of the staking app, we need the server to complete, right? That server can fall over. Even if we have multiple servers throughout the world, those servers can fall over. What you need is a system that is as resilient as Ethereum, something that has been up for 10 years with zero downtime. And so to create some system like that that will make sure that this staking app moves to the next round, the trick comes down to incentives.
Incentives are really important. Basically what you do is you build your smart contract to say everyone can deposit funds and then at some moment in time anyone in the world can poke this smart contract, anyone can make the transaction and whoever does it gets paid a hundred bucks. And so you have a whole world of people incentivized to push that button and whoever pushes it gets paid for it. And when they do push it, it moves us into the next state. So you kind of have this state machine that makes its transitions through these incentives.
And this is a really kind of interesting insight into how you build smart contract apps. So, let's say uh we've all deposited. Uh we get to the point, someone pokes it, we move into the next state, and basically when someone pokes it, there's a little piece of code that says, "Have we collected enough money? If we've collected enough money, then we're going to move into a success state, and that money is going to go buy the island. Uh if we didn't connect enough money, we need to move to a withdraw state."
This is the important part, right? If people, pirates who don't trust anyone, have staked their money into this contract and we weren't able to get enough money to buy the island, we need to go back to a withdraw state and all the pirates need to get their money back. And pirates like stealing money from other pirates, right? So, if there's any way you can lock someone's money up or steal someone's money, they're going to try to do it. And you need a system that does not allow that.
You need to write your smart contract so no one's money gets locked up. And if we're not able to coordinate, everyone can withdraw their funds. So at worst, they stake their funds, they fail to coordinate, and they withdraw their funds. No one loses their money. No one's money gets locked up.
And that's your job to write this staking app. And that's the first challenge on speedrun ethereum.com. Then there's a token vendor. You'll deploy an ERC20 token.
You'll build a second smart contract that sells that token. So then you can kind of set a price in your smart contract for what someone would pay for that token and then you sell that token to people at that price. This was kind of like the ICO craze of 2017. People were making you know millions of dollars in 15 seconds uh in you know by selling an ERC20 token. This is now getting like speedrun where now these cycles for pump and dumps are happening in like twohour phases.
Uh it's definitely like a race to the bottom, but tokens have a lot of also interesting value. And if we think of if we forget pump and dumps for a little bit and we look at real world assets and tokenization, there's a lot of really interesting things happening in the world right now with with tokens, uh but also some garbage and some pirates and other things. Now, let's say you want to make a game. when you want to make an onchain game. And and first of all, like sometimes when I talk about onchain games, I like to say you may not want to build like this fully featured game universe.
When you're building games on Ethereum, you may want to think about just building like an inventory system or a module system or some small reusable module that anybody else can build. And that's kind of the beauty of building on Ethereum or on a blockchain that's public, that's open source is any little module you build and deploy, anybody else can extend and use permissionlessly. They don't have to ask you permission to borrow your inventory system. They don't even have to go to your GitHub and fork it. It's already onchain working and they just use it.
Now, they could like go fork it and and use it and change it how they want. But a lot of times when you build a module and put it on chain, like unis swap v2 is beautiful. It's this cool swapping system. It's really easy to see and use. Uh you can go build a smart contract on mainet right now where you just send a little money to a contract.
It goes to unis swap, swaps it to a sable, sends a stable coin back. Beautiful modularity, super clean. You don't have to go ask Hayden from unis swap's permission to use it. It just all works, right? And it works, by the way, through liquidity, which we should talk about in a second when we talk about the decks, uh which is a fun kind of uh rabbit hole to go down, but we're talking about the dice first.
If you're trying to build a game with randomness, it's kind of tricky because you're on a public deterministic blockchain. It does exactly what it's programmed to do. It does exactly the same thing every time. So there really isn't any randomness. You can imagine all these validators all over the world running this code.
They can't each get a different random number, right? They're all going to get the exact same thing. So to do randomness, it's kind of tricky. There are ways like you can go to an oracle and get VRF. Uh there are ways to do a commit reveal.
Uh but a lot of people uh kind of do this lazy thing by using the previous block hash. And that's what happens in this dice game is there's a game you can pay to roll the dice. Uh it uses the previous block hash to get a random number and then if you get a certain value, you get paid back. Well, what's tricky about that is you can actually build an attacker contract. And that's what you'll do with this dice challenge.
you'll build an attacker contract that only rolls the dice looking at the block hash if it's going to win. So, there's this dice game and you build an attacker contract that allows you to only roll if you're going to win. And you'll get in there and you'll figure all of that out uh pretty quickly. Okay, so now we move on to the decks. This is this is where we're starting to get to interesting territory.
I think this is the title of this talk. Uh the building a dex is definitely your kind of your your uh awakening moment into getting into Ethereum. Uh a dex is uh what has been coined by Jacob from Zora as a hyper structure. So a dex allows you to swap two tokens. Uh before a dex if you wanted to swap token A to token B you had to go to an order book system or over the counter or some kind of escrow.
something there was centralized uh with an orderbook system. It was still settling on chain in a smart contract, but what you would do is you would sign a message that said, I I want to I want token A. I have token B. If you give me 10 token A, I'll give you 10 token B. And you sign that and it goes into a centralized order book.
And then someone comes along and and makes that trade. They take the signature, they put it on chain, they send in their tokens, you get their tokens, they get your tokens. pretty cool that you can swap tokens. Uh but it's centralized, right? With that centralized server, it has all the problems of a centralized system being it can be censored.
Someone can decide not to let you swap those tokens and it can fall over, right? The the actual server that's holding those can fall over and quit working. And and these two kind of key things are why you want to have a decentralized system. You want it to always be on and you want anybody to get to it at any time and no one to be able to censor them. And so building a decentralized version of this exchange is kind of tricky.
And the way that they figured out how to do this is by providing reserves of both assets loaded up in a smart contract. So to make it available for you to swap from token A to token B inside of a smart contract, you need to have reserves of both of those tokens. So, we'll have a h 100,000 token A's and a 100,000 token B's in that
Automatic transcript — names and jargon may be misspelled.