👩‍💻 Web2 to Web3 🚀 - Week 2, Day 1: Scripting and Smart Contracts! Providers, Signers, and Wallets

Web2 to Web3 Curriculum · 14 Aug 2025 · 1:24:39

Austin Griffith, Eda and Carlos begin week two of the Web2 to Web3 curriculum with scripting against the blockchain using ethers.js. Carlos builds a project live, covering Node versions, providers such as Infura, environment files, reading block numbers, ENS names and balances, handling big numbers, wallets and signers. The group then sends transactions on a testnet, explains the difference between mempool and mined transactions, works through a Rinkeby mistake, and finishes with the speed benefit of a local node as provider.

Speakers

Topics

From Web2 to Web3 Curriculum, hosted by BuidlGuidl.

Transcript

What's up? I'm Austin. I'm here with Eda and Carlos. We're on week two uh of this web 2 to Web3 curriculum. And in week two, uh it's all about scripting, right? We're we're going to dive into how to write scripts to talk to the blockchain. We're going to look at providers and signers and ethers.js JS and format ethers and par parse ethers, things that you run into all the time as a builder, but if you haven't yet, we're going to get you exposed to them. Uh, hopefully you've gone through week one already and you are an Ethereum power user. You've had a bunch of frustrating moments with wallets and gas and all sorts of stuff like that.

And so this this like what what did we do before? We did MetaMask. We used Ether Scan to check things. We use like unis swap. Uh we did an ENS domain. We even took out a loan on a and talked about like that that part of the ecosystem and DeFi. So DeFi, Dows, NFTTS. I don't know if we did much Dow stuff, but we did a multi-IG, right? We were part of a multi-IG. So hopefully you've you've you've gotten enough out of the first week that you can just go use Ethereum and get through some of those frustrating times. And now we're going on to week two where we're going to talk about scripting. And really, if we only had one hour, we would have you go straight to solidity and start

building smart contracts. But since we have you for this extra time, we're going slow and we're going through these other things and trying to leave as few blind spots as possible. All right, are we ready for week two? Carlos and Eda, how you guys feeling? >> I'm ready to go. You know, I always like to start like coding first because I guess this is like a more like bottom to top approach, right? I I like to code stuff and then I start like start understanding things from there. You know, some people might might prefer like understanding the theory, the ecosystem or whatever. But for me, I >> get your hands dirty.

>> Yeah. And then from there, I keep building from there. So, this is my my favorite week for for now at least. >> Yeah. I'm super excited. Like these are very I think primitive stuff which a lot of times are like not super dived into so I think it will be like nice to go through them. >> Awesome. Awesome. Okay. So I think Carlos are you going to kick us off like what's the what's the best place to get started? >> I think from the beginning right like let's start with a with an empty project and and see what happens.

>> Sounds good. >> Okay. Can you enable the screen share? >> Oh yes. I forgot the screen. There we go. Now you can share and I'm going to just basically follow along on my own machine too. So we'll probably have different versions of node. >> Let's see what is my node version. >> So can you see my screen? >> We've got a background. Yep. >> Okay. >> Beautiful C. >> Okay. Now this is a console, right? And my ID. Okay. >> Yep. Got it. >> Okay. So I just created like a like an empty ethers uh scripts folder and um so yeah maybe we should start with with uh with the requirements right like we

will need nodes for for this. Um not sure if we want to cover how to install NodeJS but it will be pretty easy to do if you there are like a plenty of tutorials online. Um what I would recommend is using something like like N I don't know guys if you have heard of uh N before it's like a like a node version manager. So you can >> is that like NVM? So NVM is another one right? Is it a similar thing but different? Okay.

>> Yes. Yes. I think it's the same the same thing right? >> So yeah, as you can see here I have like three versions. So I can pick whatever I want uh and it will change in my system like in in you know one second. So this is super useful when you are working on different project that require different versions. So right now I'm in node um 16 I think. Yes. >> Me too. >> Okay. Cool. Um >> I've got 14. I'm a bit back. >> Perfect. >> Yeah. Yeah. That's perfect. That's perfect. So maybe we will encounter some some issues with with the version. Okay.

So maybe um any of you want to explain what ethers is before I I start before I install it. I don't know or I leave it that >> it's just like a JavaScript library to help you communicate with Ethereum I think is a good way to put it. Like there's going to be a lot of helpers where once you go talk to Ethereum, Ethereum is going to give you things back like big numbers and like what the heck is a big number in JavaScript? the numbers are so big on in Ethereum that in JavaScript we can't even track them. So we actually create a special object to track numbers. So things like that just like all these helper functions and features that are are going to help us communicate with Ethereum, format things in certain ways, talk to smart

contracts, send value around, create signers and wallets. All of that stuff is going to happen within Ethers.js, JS which is just a helpers JavaScript library with very few dependencies. Rick Rickmoo has created a library that is very lightweight and used by a ton of people in the space. And I think you mentioned web 3.js. We should probably also mention that there's an alternative to this that's a little older called web 3.js that is also just like a JavaScript SDK that allows you to or library. I don't know what the difference is. a JavaScript library, a little lightweight library that lets you do a bunch of things like talk to things on chain and format values and and stuff like that.

>> Yeah, but for some reason it seems that most of the people are using eithers right now. >> So So yeah, so we will go with ethers. Okay, so first thing let's uh like start the the project with npm in it. When you install a node, npm should be there for >> so we need to be in a specific folder though, right? Is that right? So C CD and like actually make a directory and everything. Is that right? >> Yes. Yeah. Yeah. Sorry, I already created like this ether scripts folder. >> So yeah, you you probably want to do that first. Yes, >> I'm going to do that too. So make directory ether scripts and then cd into ether scripts >> and then mpm in it.

>> Yes. >> All right, I'm in. Here we go. >> And I think like we can leave the defaults at least for for now. Okay. And now uh I'm going to do like a a little thing. This is just like a personal preference. Uh but let let me hear what you what you think about this. Um so by default when you have like a node u let's let's create like this tests file. Just one second. When you have like a node um program, you usually do things like um whatever leaf and this equal to require whatever leaf, right?

So this is called uh common GS. This is just like a way of of doing imports, right? So what I like doing is like switching this mode to to the ES6 H import, right? And I will explain why why I prefer that. But to do that you can do two things. You can create like a new um property here called type and you just write module. >> Um you can also >> type module. Okay.

>> Yes. Type module. Oh is the the font size bigger? >> Oh no you're good. No. Got it. No it was the it was the the accent that I couldn't read through. It's my old man ears. >> Okay. Okay. So, so when you have this, you can also have instead of test. Yes, you can also do test. M yes, it will do the same thing, right? Uh that's like module. Yes. But I prefer like to set up like on the on the project. So you you don't have to do anything else. So in this case, you can import stuff like this leaf and then from whatever leaf, right?

So this is the same thing that you will do in React for example in the front end right. So that's what I like it because it is the same thing. So you can do the same thing in node and and in react when you use webpack or something like that it will compile the same thing. So I prefer to do this because uh I guess interoperatability right so you can like copy and paste the code from from the back end to the front end. >> So like I said this is like a personal preference. You don't need to do this to do that if you want, but I tend to do this to do it on all my projects.

>> Sounds great. So, and and again like because we're using create react app or like maybe you're using X.js, some something is using Webpack and so all of this stuff is going to use imports already. So, it's great to have your little script be copy pasteable into Scaffold ETH and everything eventually. One thing you created test.js and I created index.js. Is that a preference thing too? Does our does our node does our file need to be something specific or does it not matter? >> Like we are going to call our script directly from node like node like test yes or no index yes. So doesn't matter.

>> So create whatever JS file you want there. >> Yeah. Yeah. I'm actually going to delete this one. I just I I just created to you know the >> Oh to show the imports. Got it. >> Yeah. Okay. So I guess now we have the project set up the let me open a terminal here. Okay. So the first thing that we want to do is installed ethers right now we don't have like any dependency installed it's just like node so let's install he ethers with mpm you can say i or install I think and it's just like this >> mpm install ethers send it >> it will take a few seconds and you will

see that your package it will update has a new dependency. Yep. And there's a package lock that comes along with it. Very nice. And we've got a new node modules folder. >> Yes. So the the lock JSON because if you see here, you can see that this means that it's going to install like any Heather's version up to I think six. So So six is is not going to install, but it's going to install like 599 or or whatever. But if some if I push this to GitHub and someone uh pull down my code uh when you they will do like npm install and that will install all the dependencies but that will look into the pack log JSON which is because here you don't really know the version you you

you just say here I want to install this version or app but on the log file there's like the specific version. >> Yes. Yes. Yeah. >> So you see here is like the >> well not this one. So some somewhere should be like the individual version or >> somewhere in there. That's what the package lock is doing. And you do add it to your git. Is that right? Like the package lock goes in the git. So then if someone does a git clone, not only do they have the package, but they have the package lock and when they do the install, it gives them the exact version that you are working with.

>> Yes. The lock is just like to lock in like a specific version. >> Cool. >> Okay. So now we have ethers. So now we can create the a new file. Let's call it uh like um let's call it providers because we are going to start with pro with providers. >> We're going to touch providers.js. >> Yes. >> Got it. >> Okay. Now I have empty file and remember we are using ES6 and so let's import ethers. Uh >> I always copy and paste these lines. I this is this is good to go through like slowly and type them ourselves. It's good for me like just for your brain.

>> Yeah. Sometimes I do the same right like if you go to ether's like the package of the GitHub that you will probably read the instructions and you you will just like copy and paste. Yeah. >> I don't know. >> Yep. >> I'm just like playing it fancy here like typing all the stuff. >> Yeah. No, it's good. That's what this is all about is going slowly through it so folks at home can watch and follow along and understand things and digest. >> Okay. So I think um ethers like Austin said provides a bunch of utilities to interact with Ethereum blockchain. Uh but I think like one of the more powerful concepts in ethers is the concept of providers and signers. So I think we should start with that right

with with at least with providers. We can get to signers after but let's start with with providers and um I I come from a like a web develop like traditional web or maybe web two development. I don't know if that's how people call it now like web two or traditional web two development. So the mental model that I have when I think about uh providers is just imagine that in your web two application you have like um you know like a a third party service like like Firebase for example right you use Firebase to store uh some some data and in order to do that you will need some kind of API key right which probably Google is going to provide that API for

you and they say okay use this API and then with that API you can access fire and you know and save some some data. So Google is acting as a provider. So this is if we move to to web 3 uh remember that we are trying to be decentralized uh we want to access the Ethereum blockchain right and we need a provider for that right so that is like the mental model that that I have so it's like accessing like like a service so I'm using a provider to do that and since we are trying to decentralize and be decentralized uh you can choose a bunch of different providers right like you have like for example any node like this node right here could be a provider

for us and I could just point to that IP address any node on the network that's communicating peer-to-peer to all the other nodes any one of those nodes can be a provider sorry go ahead >> no no I was going to say like people usually uh before like sharing their own node what what they probably use is something like infura right or alchemy they're like like two providers I guess those are like centralized companies I guess but whenever you want you can also like Austin said, "Set up your own provider, right?" Like, yeah, I think I think maybe now is a good time to explain what you have behind your back because I'm sure that people are wondering from from since the beginning that what is that like matrix like uh >> Whoa. Yeah. So, this is an ETH. This is

a an ETH uh it used to be called an ETH2 node, but this would be the uh the validator and or no, this is the beacon chain and this is my validator node. And when we merge and and it's all talking to this right here which is uh my uh ETH one like layer one. So this is this is like what a GU node is or this is ne nethermind and then this is prism beacon chain and prism validator but basically it's the stack that you need to have the whole chain uh locally and I'm not I'm not mining on L1 but I'm on layer 1 but technically I will be mining blocks with my validator I'll be validating when we

move to proof of stake but just consider all of this stuff behind me just like one node of the network that's talking peertopeer to everyone that has the entire state of the blockchain ready to go and you can ask it you know what's the balance of this address or what's the what's this specific variable value in some smart contract. So basically this thing is talking peer-to-peer to the rest of the network and I can talk to it as a provider using my web app or one of these scripts and it'll just make an HTTP request to the the RPC and the RPC will return depending on what I ask for certain things. Is that a good way to put it? Like it's kind of like a little API that I can call to and ask it certain things. What block number are we

want on? What's the balance of this thing? Etc. >> And you don't have to trust anyone, right? I mean it's your own node. So it's not like a company giving you information. It's like your own node. I guess that you have to trust like the software that you are running. Yeah. >> But still right. >> Okay. Um so the the quickest way to I think it has this get default provider. Um I I don't know if you have ever used this uh but you can use like this default provider with either but it's not this is like only for like for testing purposes right because this is going I think internally ethers just use like some uh non API free tiers from some services. So this

is this will break right if you put like like 10 requests in a second that this is going to break. But this is the the quickest way to instantiate um a provider. But usually what you want to do is um getting like um I think Infura or Alchemy. I don't know. I always use Infura. I don't know why, but I think I started with Infura, so I keep with Infura. So, in Fura, let's let's check the the the website, but I think it allows you up to um I think it's 100K requests per day, something like that, for free, right?

And and what they're doing is basically they're running a bunch of these and they have like a load balancer on top of it probably. And that means they have to keep all their nodes up to date and all of them in sync. And then they have this whole, you know, you know, thousands of people making requests to it trying to get the information from the chain. And so they have to charge people. And so you as the developer probably end up with, yeah, some free tier at first, but then as you push your application farther and closer and closer to production, you'll probably want to get um a more advanced Infura and Alchemy key so it doesn't fall over in the middle of the day uh when you hit that 10,00 request limit.

Yeah. So the way to instantiate that infura provider is just I think it's either provide there's no it's let's see how how it was. It's um >> like a JSON provider, isn't it? >> I think it's new, right? >> The one we're doing. >> Yes. Providers and then it's JSON RPC provider. >> And that would be like the Infura ID, right? Um Infura ID. Okay. Um, so, >> oh no, that's going to want to go to a an an address, right? The Infura ID probably won't go into the that that probably needs to be an Infura provider.

We do want that JSON like I'd steal that JSON RPC provider and tell it to go to, you know, localhost port 245 and talk to this one. But I think if you want to talk to Infura, I think it's a different provider. Let's see. We should probably pull up the Ethers.js docs, too, and provider. Something like the something like this. I have it here. Yeah. Let me paste it. Let's use a template syntax.

>> There we go. >> Something like this, right? >> Yep. >> And this will be on your on your panel in Infura. Um, okay. So, something like this, right? This will work. So now what I what we need is some infur ID. Um I have some uh uh but usually when you when you use uh like um this can can be seen as a API key right so usually when you you don't want to expose um an API key in your code because if you push this to GitHub like everyone will have access to your to your >> and is this the secret key like from froma you have like a key and then a

secret >> I think this is just the key >> the And if you keep the key, yeah, if you keep the key secret, then you don't have to worry about it. But with a lot of web apps, you will deploy the app with the key in it. Yes. And then you'll have to set some security that says >> only allow requests coming from my domain.com. So then once your your domain goes live, then only requests from your domain count toward your rate limiting on Infura. But for now, let's just keep the key and we'll keep the key quiet and we won't have any of those domain security issues. We'll just keep the key in like an env file or something.

>> Yes. Paste it right in. >> Let's do that real quick because it's super easy to set up. And we can install M. It's just like a package to to manage this H environment variables. And it's super easy to use. Let me let me install it and I will show you how how to use it. It's already installed. Um yeah, let me >> Here's the Infura provider, too. Oh, env. Nice. No, these are great things to go through. I like how we're like going through these slowly and kind of covering them.

>> Okay, you see here like um it's just super easy to use. Um this is um the one that we want to use because we are using ES6. So, let's just paste this on top. And usually what what you do with this is um create uh embam sample and then in this file you will have like I don't know if you are key and this you leave this empty right but then when people clone your your repo you will see that it has like AMP

example file and maybe in the instruction you can say okay now when you have this file you just have to copy this file to M and you will probably also want to get ignore this file I might be doing like a a bunch of things at the same time sorry about that but >> no this is great and we're covering everything so it's going nice and slow like take your time keep covering it I think we're doing a great job I'm following along Okay. So, so this g ignore uh file is just a file that tells g to ignore some files. In this case, we want to ignore node modules because because we don't want to to upload our node module folder. That folder will be

populated whenever the person that clone your repo do like a mpm install. And we also don't want to push the M file, but we do we do want to to push the MX amplifier. Okay. So now um I can copy this and I can paste here my my key. Um so let's let's do it secretly if you want. Let's do it this way. >> And I'm going I mean it doesn't matter.

Okay. This is like exposing in a scaffold if >> just to okay. >> I'm I'm in my own Infura kind of getting my own Infura key set up too. So I'm going through the same thing. >> Okay. So now uh what we can do here um since we imported like M config here um we can we have access to the environment by so we can do process I think it's process right process dot I think amp and it should be infura okay I think

yeah for some reason I Wait to some reason I don't have the NS. Yeah. Okay. So, any questions so far like EDA or Austin? anything that we that maybe is not clear.

>> So the uh in this case we're using a JSON RPC provider. We should note that there is like an infura provider. If you're if you are like all of these different like this is the best way to do it because it's the most generic because we can paste in an alchemy address with a with a a key. We could paste in an IP address, right? But there also is an Infura provider. Uh yeah, if you go to ether. Yeah, I feel like we should probably just like highlight the ether's docs. They're kind of hard to look through sometimes, but this is where a lot of the information is going to be. And there's even probably an Infura provider there where you just put in like >> Yeah, there is Infura provider that second one.

>> Oh, second one. Oh, yeah. This one >> where where in this case you're just saying what network. So, so the first argument you put in is, you know, Rinkabe or Homestead or whatever. Homestead is mainet, by the way. And then you put in your API key. So, so instead of like crafting a URL, you could just use this Infura provider if you wanted. >> Yeah, like sorry, like something like this, right? Providers if you have provider and saying uh and this would be this thing, right?

>> Yeah, there we go. This would be Yeah, like say like this might be like more generic, >> but yeah. >> Cool. Just wanted to point that out. Just say that there's there's some other options. >> Yes. >> Uh just so we know. >> Alchemy, Ether Scan, Cloudflare. Yeah, you have a bunch here. >> Okay. Okay. So, which one do we want to keep? >> Uh ju probably just the the JSON one. After all of that, it might be easier just to have the generic JSON one just so we can plug some different things in there.

>> Okay. So now we are connected to a provider. So what's be like the first thing that we can do? What do you think? >> Block number. Can we like the first thing I usually do is like what is the current block number just so I get something back and I see that we have something coming from it. >> So that lets you know like how big the chain is basically, right? And the biggest chain wins. And we'll cover that on the very first day probably. But yeah, getting a block number from a provider I feel like is that are you alive and are you tracking the chain the same as Ether Scan shows, right? We'll we'll get the block number here and then we'll go to Ether Scan and look at the block number and make sure those things are keeping up in sync.

>> So a question. What do you think that this is going to this is going to >> trick. It's a trick. We needed on a wait, right? There's no async await here. Yep. Okay. Let's go through it though. If you're a brand new programmer, you grab the provider, you say get block number, you run the thing. What does it do when it runs? >> And you're ready. You're ready to see the block number, right? You're ready. >> Give me the block number. >> Oh, it's a promise. So yeah, like I if you are new to to JavaScript like maybe maybe we can like post like some links to to this stuff, but you will probably need to read something about um a synchronous code and promises and and callbacks and a sync weight, right? Um so yeah, the

thing is that this is um when we uh execute this line h the code doesn't stop here like it just keep going. So it's just like print the promise. So we we need to wait until the promise finished to show to to see like the the block number. And remember that I mentioned at the beginning that I like like this way of doing like the ES6 module type. This is another reason that I like because you can use a weight just here on the main thread. um when when you usually if you don't use this module this ES6 modules you need to do like a function and that function need to be a sync and then you can use a weight inside but with ES6 and

I think node 14 I think you can also use a weight outside of the of any function on the main thread that's another reason that I like um this ES6 modules okay what about now. So, does it work? >> Did we get a block number? Let's see what happens. >> Yes. >> Hey, and it's not even a big number or anything. We just get a nice current block number. >> And Oh, that's great. And And let's go check Ether Scan real quick and make sure that's where where we're at on Ether Scan.

>> Okay, we got like um 629. 629. Oh, 629. Yeah, here. >> Yep. So we just got like the latest block number over there, >> right? >> Yep. >> So if we run again, we should get like a new number. Yeah. 34. >> Oh man, a bunch of blocks passed. Yep. Exactly. Yep. >> But now let's do something like more juicy, right? Because the number I mean is nice like Austin said just to get like the number >> connected. You know that they're out there. Yeah.

>> But you can't really do much with the blog number. Say, "Okay, I got the blog number." But we can do something like um we talked about ENS last week, right? So ethers have um I'm going to comment this um ethers also have a way to resolve hs name to addresses right so when you're in a provider you can do something like provider I think is name resolve name yes and let's do um it was like atg your address >> yeah atg Thomas Griffin Oh nice.

>> I didn't know the T. >> Yeah. Yeah. Middle name. There we go. ATGE is >> Oh, provider.resolve name is what we're doing. Cool. >> Now, let's see. >> Boom. Is that your address, Austin? >> Uh, yes. 34. Yeah, that's me. That's me. Is that You're like a magician. Is this the card you >> um Okay. So, >> and so that went to the ENS contract and it put in atgeth and it got back the address. So, it went and talked to a specific smart contract and in this case, Rickmoo has built a function for you to go talk to that specific

contract. Normally, we'll go talk to random contracts and we'll use something else. But in this case, we're interfacing with a smart contract with a with a customuilt uh interface that Rickmoo put together just because this is a specific contract that you're going to talk to so much, he just added the functions to allow you to resolve names and and and uh look up addresses. >> Yes. And also maybe you might remember from last week that we were complaining a lot about people when when we were on I think was winky and we were connecting to any app like they didn't they didn't resolve the ENS back right so because when you connect to app they can only see your address right so when you when

with your address they should go to mainet provider and get back the your ENS so you can also do is the opposite way. So now I'm I have a an address here. Maybe it sounds familiar for someone, but I'm going to do lookup address. This is the other way around. So we we do we did like resource name and it goes from an ENS domain to an address. And lookup address do the opposite. It is goes from an address to an ENS name. So let's paste this address and um let's see here comment this. So this address is and

let's see who who is this person. Oh, look at this. >> Look at this. >> That's me. Edit tweets. I thought it maybe it was going to be Vitalic, but it's edit tweets. >> I thought it was Stamford. >> It could be Stanford, too. We got so many identities. >> Yes. Okay. Um, so what next? Maybe something that we can because we didn't mention >> maybe.

>> Yeah. We didn't not sure if we we say it, but when you connect to a provider this way, you only have read access to the blockchain. only read you can only read data from the from the blockchain you can write or you can't send any transaction because for that you will need assigner which we I think we will get there later but let's keep with with providers so another thing that we can read is balances right so let's let's um let's get uh the balance of uh as you mentioned I'm sure that he has more than us so let's let's check his account Italy.

>> Yeah. Yeah, I bet he does. >> has uh Okay. So, for this um you can use I think it's just get balance, right? Get balance. Yes. >> A bal is it balance? Is it get balance? Yeah. >> Yes. And here >> balance of is like in a smart contract I think. Yeah. >> Yes. Awesome. >> And here you have an address or name. So you can use uh uh you can use um an ENS or or an address. So let's use it uh ENS. And what do you think is going to happen here?

>> This is another trick. Yep. So normally we would think we would get a number back, right? We would get the balance of this address. But since we already alluded to numbers on Ethereum are so big that JavaScript can't even track them. So what we're going to get back here uh is probably this some kind of a big number object and we can learn how to deal with that. >> Yeah. So you as the developer you're like okay vital balance is big number underscore hex underscore is big number WTF.

Don't worry developer. This is just because it's such a big number that we have to store it in hex. JavaScript can't mess around with it. But how do we convert this into something a human can see? Carlos, >> um I think you also mentioned last week because there but the reason that solidity or the EVM doesn't have uh I mean use this notation or these big numbers is because we don't want to deal with floating points, right? Because that that is hard to do and it will require a lot more logic. So they just say okay let's multiply like every number you know up to the 18 so we have like this big numbers but then when you do like the opposite when you go from JavaScript and read a variable from a contract you are going to get this big number because if not it will overflow

maybe not always but in some cases can overflow so ethers also provides some um I mean I guess you can do this let's let's do this first not not to number don't do that But >> I mean let's try all of them and see what they do. Yeah. >> Okay. So yeah I mean because if you do to number that is going to try to convert it to a number and that might overflow and break JavaScript. But if you do >> with italics with italics balance but not with my val my balance. >> Yeah. Yeah. It won't happen with my balance. Yeah.

>> Let's see what happens here. Two string. Oh, we get a promise. >> Yeah. This is because we need >> you have to await that whole thing. There we go. And then go two string. Yep. Perfect little thing though. Like a developer could get stuck on that little thing for 10 minutes and like what the hell is going on. So yeah, there we go. Look at that. >> So I hope that he doesn't have this kind of ETH, right? This is not E. >> That would be a lot of >> Yes. So this is actually a is way right is way or Gway is way, right? >> Uh not Gway. Gway would be like what we measure gas in. This is way we Yep. Yep.

>> Okay. So, let's let's well let's save this here. I did this. Uh >> basically, what we would do is go over 18 decimal points and put a decimal in there is what you would do if you were man manually looking at this. >> Yes. Like counting this and maybe >> 18. Yeah. Yeah. >> Yeah. I'm not sure if it's going to be like 421 or 4,000. I don't know. >> I don't know. >> Let's see. Okay. So, so ethers have um some utils to deal with these big numbers. And one of um this util is called I think it's uh is format. Yes, format, right? Yeah. I always get confused because there's like >> we're here to not get confused about those. There's format ethers and parse

ethers and we want to show you you at home, you're going to get confused, but we're going to keep throwing these at you until they stick. Yeah, I think it's format because when you ever when you read, you know, like a number from from from a contract or whatever, you want to format in order to to display, right? And the other way around, when you have something that you want to send to a mark, you you want to parse your your number to and convert it, right? >> So, I think this should work. Okay, so it was for >> Wow, that's a lot. That's ETH. He has that much ETH in his Holy cow. Geez,

Metallic. Let's double check that. >> Let's look it up. Let's go to a disinterested third party, right? Let's go to Ether Scan. Oh, yeah. No, he has $8 million worth of ETH in his account. >> Okay. >> Good lord. >> Then can we borrow one of those million dollars? How many developers can I pay for how long? Yeah, maybe we can try with ethers. Maybe ethers and have like some hidden function to to get some balance from from the okay so let let's since we are here let's show the other way around we talk about the ether's utils parse ether right so if you want to send let's say maybe

>> a string make sure you put a string around this don't put like 1.0 that's gonna you're gonna have a bad time yes >> you need to put 1.0 zero in the quotes. Yep. >> So let's do 1.5 >> and then >> this should return uh like the So this would be like one point if is >> Yep. >> this this way, right? >> Yep. >> Let's see.

>> Yeah. You see? So, so it just compared to the to the big number >> and if we if we do this this to a string >> it will show the actual number. Yeah. >> And if you did ethers.utils.format ether around the parse ether you should get back to 1.5. >> Yes. You want to do it? Yeah. Let's let's do that. >> Sure. Sure. There we go. Yep. Does this make sense now? Okay, let's see.

>> 1.5 ether is 1.5. We did it. >> Okay. Okay. >> Okay. So, we've got format ethers and parse ethers. And this helps us go from and to big numbers. Uh sometimes there it is an actual number though, right? Like if you have some counter that's just keeping track of like a UN8 in your smart contract. Yes. You you will just do a two like a dot two number and that's fine. But if you're ever if you ever have a big number and you try to do a dot two number, you're going to have a bad time because you're going to get overflow because it's going to try to take a big number and smash it into the amount of bits that you have to keep track of a number in JavaScript and that's where it's going to fall apart.

So in your app as you're building things, say you need to pull down a couple of these big numbers and then do some math. You don't want to convert all those big numbers to JavaScript numbers and do the math within JavaScript. You actually want to do the math here as a big number. Maybe maybe let's add two big numbers together and show that off real quick or something along those lines. >> Yeah, I was going to say that you can use like big numbers have like some operation on it. For example, let's do like the Sanford balance, right? >> Okay.

>> Sanford uh Sanford. >> I think it's s an N. I don't think there's a D there, isn't it? >> Sanford. >> I think it's I think it's Sanford's. Yeah. Something like that. >> So, you can do with big numbers, you can do things like um >> Yeah. >> So, this you can you can do something like um I don't know. Uh >> this is perfect. Yeah. Let's do like um well let's do like a old school like if here so >> so Vitalic has more money than Sanford in this case.

>> Yeah >> that's probably I mean I'm going to do like the else but I don't think that we are going there. >> Yeah >> maybe on local host. Okay. So we are because we don't want to to do operation with number with big numbers. We don't want to convert it to to number and do operation in JavaScript like big numbers have this kind of uh you know operators where you can do like compare or maybe add or something like that. So let's let's see what happens here.

>> On line 22 you have Sanford twice. It's like a small thing but you might want to put Vitalic. There we go. Yeah. >> Yeah. And then I think to even so Vitalik has more than Sanford. We can see that for sure. Now what happens if we take the Sanford balance and we add >> like 5,000 ETH to it, right? So I think you could do Sanford balance add uh right right in line. Oh, I see. You're going to do the whole thing. Yep. >> Yeah. I think if you want to add like what what do you want to add like five E for example, right? like or no, let's add >> No, let's add 5,000 to make sure we're So, how many? So, he has he has >> 4,000, right? So, let's add 5,000 E to it. Good. Lower.

>> I'm not sure if this will work or I have to convert it to >> Yep. You'll need to do a utils. You'll need to do a parse ether. >> Something like a big number from. Yep, you could do that too. Yep. I was going to I I would say to do a parse ether just because we know format ether and parse ether. But this is another way to do it is just create a big number from 5,000. >> Yes. >> Let's see what happens now. >> Let's see what happened with Vitalic now. >> Come on. Sanford have more money than Vitalic. >> Oh.

>> Uh oh. What went wrong? Maybe Sanford balance needs to equal You need to do Sanford balance equals Sanford balance add. >> Yeah. Yeah. Yeah. >> Yeah. And it's const, so it's not going to like that either. Yep. There we go. Now be bigger. >> What are we waiting on? Is it like querying? >> Oh no. What? What? Okay, >> let's do this first. >> Let's do some console logs. We got something weird going on here.

>> Sanford balance. Say for balance to string. I think the weight is just like us connecting to the provider. I think >> it's you asking Infura for the information, right? Infura is super slow. Okay. >> Uh okay. So let's do like this uh format. No format either. No, not format. No. Yeah.

Format right? >> Yeah. Yeah, that's right. That's going to display it. And you take out the two string. Yep. And I think you need one more PNS. Yep. Let's And maybe do like copy that and paste it so we have italic balance also. Just make sure we're seeing all of our variables correctly here. Nice. >> And maybe he just like made a a transfer right now with >> he's messing with us. Throw in some more Ethan his account to keep up with Sanford. >> Oh man, this wait time on >> Okay, there we go.

Maybe add uh wait. Yeah. What? What is happening here? >> It's really just return a big number, too. Not sure. >> Is add not the Let's see. This is good. We want to have these problems. So, we want to go through it and figure it out. What are we missing here? Why can't you just add? >> Yeah, it returns a big number of the value plus the value. It should uh that should work and it's not. What are we missing here?

Uh try parse ether just in case. You know that big number 5,000? You know what? I think it's doing 5,000 way >> because it's creating a big number but the big number is still only at 5,000 way. >> I think I think we want to just do parse uh yeah parse ether instead of doing that big number from because what you did is you created a big number of 5,000 way. Yes. >> So it was the right format but we're only adding 5,000 to it. I think you want to just stick to parse ether and format ether at first and and not have that big number that like that because that's going to confuse you.

>> What you mean? >> There we go. I' I've got a good feeling about this one. >> Okay. Yes. >> I'm glad we went through that though. That was a really good like exercise like why isn't this number why are we getting this small number and we have to really like count it. There we go. Stanford has more than >> we did it. >> Yes. >> So again like just to go through this stuff we've got providers. We're asking the blockchain you know who who is behind this address or behind this name. We're asking the blockchain what what is the current block number. Uh and then we're getting in here and we're actually doing some conversions between the format ether and parse ether to go to those big numbers. And it's just this is like you'll deal with this stuff on a

daily basis if you're a decentralized application builder. So this stuff is just so good to go through and like go through this a few times and test your assumptions and have lots of console logs and and get it so it's like clear in your mind what's going on. Even us that we like we've been building these things for a year or years, we still like it took us a few tries to get it exactly right. >> Okay. Um, what I have next in my list is wallets. I'm not sure if you want to cover if Eda or Austin want to cover anything else, but the next thing in my list are wallets. So, up to you.

>> Providers, signers. How about how about just like a small little bit of contract interaction? like could we ask the uh the balance in die of each of these people, right? So get Vitalik's balance in die and get Sanford's balance in die because right now we're doing we're getting their balance in terms of the ETH balance, right? But to get your die balance, we we'll go to a die contract and we'll we'll ask for it and that's going to bring up things like the ABI and the artifacts and stuff like that. Yeah. I mean, I think that was like planned for for another day, I think.

>> Okay. Okay. No, that's fine. If we're already here, like, >> but we can go I mean, it's up to you. Uh, >> no, no, no, no. If if we're if we're if we're going to hit that tomorrow, let's hit that tomorrow and let's look at wallets today. I'm down with that. I'm I'm following your lead, Carlos. You go for it. >> So, yeah, my idea was to do wallets and maybe like a little bit of signers. Just like an introduction of signers because we need signers to send transactions. So I was thinking like tomorrow maybe we can like start like getting some data from the smart contract and sending some transaction from the code. >> Perfect.

>> That okay? Yeah. >> Yep. Sounds great. >> Okay. So let's create a new file called wallets.ds DS and um yeah, I'm sure that um you all remember last week we created h I think a couple of wallets through MetaMask, right? And it was like a it was it wasn't fast, right? because I mean it was fast because you have to create the you just have to push some buttons but you have to you know get the you know like the the pneummonic phrase and put it just to you know put it there and and save it and all of that. So you will see that

that is going to be super easy to do in code. Um for example with either you have several ways to go um for it but the easiest way I think is um let's well let's import ethers first and from ethers and yeah I think uh you can do something like wallet uh I think ather yes create random so you Then with just that line, you can create like a new wallet. And um let's address uh let's do wallet address.

Um well, let's let's also uh print the private key. I mean, don't do that at home. >> Don't do that. But we want to do we definitely want to do it. But like goosebumps should go off when you're printing a private key. >> Yeah. >> Yes. And also even the pneumonic I think we can. So I think this is like private key and this is the pneumonic and and phrase if I'm correct. Okay. So if I just run this script wallet it's going to create a new wallet and so the private key and the monic and whenever I I run this script it's going to create a

new one. And we kind of covered what a pneumonic is and how a private key is derived from that. What we're not seeing here is that this private key is probably private key number zero of that pneumonic. And you technically could have a whole bunch of different private keys. >> Yes. Yes. I because we we create one I mean we have one pneumonic on metamask right and y if you remember we will add like new accounts with the same pneummonic. So yeah, actually let's let's dive into that because I think it's interesting to see how um how that works. So let's let's let's see let's check the the documentation in in ethers. Uh but I think uh there is something like from

pneumonic >> it's like from pneumonic. Yeah, you do from pneumonic and then within there is the path >> and the path. Yes. And I think that path you could tweak to have a different >> last number. That's so weird. Why not have >> index and Yeah. I don't know. I guess >> I guess because maybe you want to use like a different path. >> Different path. Yeah. >> I know. So let's uh Yeah, let's do this. Let's declare um my wallet. Let's see my wallet. And let's go with a like a old school for loop here. Uh let's zero. And let's do for

>> like 10 wallets or something. Yeah. Cool. I love it. >> Yeah. And then we can do uh and Okay. So we can um the path. Let's paste this one. This is the default, right? I hope so. >> Yes. >> Unless he's trying to trick us. >> And >> you want to delete the zero off of there. >> Well, yeah. I'm going to use like this template string. >> Yeah. >> There we go. Cool. >> Okay. >> I like it.

>> Okay. And now we can say my wallet is equal to ether wallet from pneumonic. Yes. And then let's use this pneumonic, right? We have it here. And then use this path. Okay. And if the very first address lines up, if the first private key lines up, we want to print the private key there, too. Yep. Oh, yeah. Or the address. Yeah. Cool. >> Let's >> And we'll make sure the first one lines up with the zero. And then they should the rest of them should increment. >> So, let's do this like to show the the right.

>> Very cool. >> And then this will be my wallet. >> Okay. So this is going to take the like the it's going to create aneimmonic and from that it's going to derive like 10 wallets and we are going to have like 10 different not wallets like 10 accounts right it's a better term I think like 10 accounts or 10 addresses from that pneummonic >> so if you run it >> let's compare the very first one with the first thing that prints >> 9A yep we did it right we've got the same address and the same private key for the first one and then you can see the rest of them would be those extra accounts that you would add if you were in MetaMask adding a new account or whatever. Very cool. Very good way to just demonstrate that too. Nice for

loop. >> Um, okay. So, another thing that I wanted to do is h whenever you have like the you you can you can go to metam mask if you want and use this uh this pneummonic and you will it will derive the like the same addresses, right? And you could also I think we didn't do this last time like to import like a single private key. I'm not sure if we did that last last time. >> Oh no, you can do that in MetaMask is what you're saying.

>> Yeah. So let's let's let's pick a number from zero to nine. I mean which number do you like? >> Key number five. >> That's five. I like >> there we go. So private key number five. >> The address start with 71. Right. So let me import this private key to MetaMask. I have it here. Oops. Okay. Yeah. >> No, this is like that. Don't worry. >> Okay. So here you can import I mean import account an account.

>> And the way that we imported one was we created a pneumonic but in this case we're bringing in a specific private key a single address. >> Cool. I'm going to paste this here and boom >> 71 >> 71 and ends on 55. >> So I think it's the same thing that we had here. 71 and 55. >> Yeah. >> Okay. So what if we wanted to create a wallet object given the private key not the pneumonic? Can we do that in ethers? >> Yeah. Yeah. I think so. So let's >> from private key or something.

>> Yeah. Let let's start with let's say this private key. We like number five, right? So let's uh going to comment this. >> Oh, you just do new wallet and then pass in the private key. Cool. >> Okay, >> here's the docs. >> So, did you paste it somewhere? >> I in chat. It's just you you just do new and then capital W wallet and then inside of the parenthesis you do the >> Okay. So it's new ether's wallet. >> Yep.

>> And then paste in the private key. Yep. >> Nice. And then we could just do like wallet address or whatever. >> Of course. Like we are I mean it was funny that we created like the M file and everything >> environment file like private key here. So yeah, don't do that please. like you you should like just go here. I mean, let's do it, please. >> Let's do it. That's a good idea. Let's do it. >> So, let's do like like my wallet private key. And then this is like for the now I'm going to No, this I'm going to because I don't want to see I'm just going to do that variable equals to

my key. Okay. Now we're back. So this is the private key. So now we are removing this and we can do something like uh >> and now we can commit it to GitHub but not worry about that private key getting lost or something like that. >> Yes. >> Getting drained. My wallet address from pract is wallet >> and it should be the 71, right? Let's see what happens.

>> Yes, this. Oops. >> Uh >> oh. >> This is good. This is good. >> Yeah. >> Okay. Oh, you know, maybe is like the Okay, wait. It's like the the zero X. You may need to take the zero x off. Yeah, let's Yep. I bet so. >> Yeah, like the zero X just indicates like there's like an X extr, but you don't really need that. So, let's >> This is exactly the kind of thing we want to have is weird errors like that.

Like that error does not at all tell you you've got a zero X on your private key. You don't want a zero X on your private key. It tells you something about hex and it's like what is happening? Why why give me that error? You at home would get so frustrated, but you went and you edited the env file and you took off the 0x of the private key, right? >> And it's still not working. So >> Oh, okay. That didn't fix it. >> No. >> Darn it. Okay. So, something is undefined. My wallet. Let me take it in. Well, I mean, let's let's print this here. We already we already have that set up.

We don't need to await the wallet address, right? Huh? Oh. Oh, okay. It's not defined. >> So, I think do we need to like pass our provider for the wallet? >> Uh, I mean it's not Well, >> no, not sure. I think only if you want to be a SER, right? Maybe >> this is Yeah, this is an interesting thing. The difference between a SER and a provider. I think you can create the wallet and then connect it later on to a provider. You could do a connect. So, in this case, we're just like locally creating the the wallet and the address.

>> I don't think it needs to be connected to a provider to get this to work. >> We we we missed the >> conf. Got it. Okay. >> Yeah. I'm glad that these things are happening, you know. >> Yes, exactly. That's that sucks that it didn't give us. So So basically what we would have done is we would have tinkered around for a while and eventually we would have console logged that my private key and we would have saw that it's undefined. Is that right? There we go. Yeah. >> So our private key is undefined. We're creating a wallet with an undefined key and it's and it's blowing up. So, we didn't bring in the process env. Okay, cool.

And now it's right though. We we see that we can create a wallet from the private key and it does derive this 71 address that that we were expecting it to derive. Awesome. >> Yes. Um, so I don't know why I mean not sure how much time do we have left. Uh but we can introduce signers if you want or we can even do something with signers or I don't know >> that that whole difference between the a serer and a provider and being connected right now we're not connected. If we wanted to get the balance of this address maybe let's go through that like okay cool we've created a wallet from a private key but we don't have any kind of a provider here. How do we bring the provider into the mix? We we could pass

the provider in as we create the wallet or we could like retroactively connect the wallet to a provider and maybe we could go through both of those steps. >> Yes. >> Uh and then we can do like signers and contract interaction next week I think. >> Okay. So let's just like copy this from here. So I think this will just connect the the wallet the account to the provider, right? I think this is one way to go and the other way is here. I think just like the second argument, right?

Okay. So maybe what uh is I think there's like a bull here called right? >> Yeah. >> So >> maybe Oh yeah. So it's it's going to be assigner. Yeah. Yeah. Okay, I see what we're doing. Let's run through this. This is interesting. >> Okay, >> because this whole signer verse provider thing is really interesting and you need to kind of get your head around it where provider is the connection and serer is the local cryptography stuff that sign. >> So it say that this is a signer because this actually is, right? You can sign stuff with this serer, right? Like you could sign a message or encrypt a message even with the >> you could sign a transaction, right?

Like if you were going to have like an airgapped machine, you could have this script running on a machine that's not connected to anything, no connection to anything, but it has the pneumonic there. It brings in the pneumonic, it signs a transaction, and then it delivers you the signed transaction, and then you take that to another computer that's on the network and plug that in and send your and broadcast your transaction. Basically, the the machine that holds the PK like never is ever connected to anything and it's airgapped, right? You could technically do that or assign a message. Yes, exactly. Hola.

>> Let's try this. Hello. Open up. >> There it is. >> Oh, it's like a promise. >> Wait, but it it gave us back the >> Yeah. Yeah. I don't know. >> That was >> like a promise with that. Yes. >> So >> So then that signed message. So you could send Ola and that signature across the network and anyone can take Ola and that signed message and recover and they should get the 71 address that we that we are using to sign and that never goes to provider that never connects to anything. All of this is happening locally.

>> I think let's do I think it was something like this right verify message right? >> Oh nice heck. >> I mean maybe this is not for today but I no >> that's great. Let's do it. It's happening. >> So let's let's store this here like signature right and then we can print the signature and we can verify I mean doesn't make sense to do it here this will be in like in another server right so you will sign this message and you will send it to someone and that someone will verify that you are the author of that message right so this will be executed in another computer so you have to pass like the the the message, right? And

then >> the message and the signature need to go across the network. Yep. >> Yes. And then I think this returns the address of the signer >> hopefully. Yeah. It should be the recovered address. Yep. >> Sign address. Okay. Okay. So, this will give us like the 711 right? >> Hopefully. Let's find out. Hooray. It did. We were able to like cryptographically prove that that account signed that message. And a lot of times you'd have a time stamp or a nons in there so no one can replay it.

But that could be that in a lot that in itself is like super powerful. You could build a whole web 3 app that doesn't talk to the blockchain at all. It just uses ECDSA key pairs signing messages and verifying those messages. And I consider that to be web 3. like we'll see like is it about decentralization is it blockchain based is it ECDSA key pair based but yeah there's a lot to go into there but >> yeah I think we we can go deeper on this like on you know in the next days about signing stuff but I think this was like a good introduction at least so the thing is that we wen connect we aren't connected yet to a provider right so what is the different hosting if I do

because now I can sign But what is the difference if I connect to a provider? What can I do connecting to a provider? >> Still be a ser, right? Like let's let's go ahead and uncomment that. It's still like all of this should still work. Let's hit save and make sure it still works. I think basically it's still a servers. It still can sign messages. But now in this case, because we're connected to a provider, we can ask the provider for the balance of this address or we could uh you know broadcast a transaction. But >> yeah, what what what if like the last thing that we can do today is just >> getting like the instead of connecting to to mainet let's connect to rink let's request some uh rinkb e from the host

and then send some some toford I don't know >> okay okay cool that sounds good so we're actually going to sign a transaction then you're you're going to do an outbound let's do it let's see what happens let's go for it >> okay so let's first um I I think this is just like rinky, right? >> I think so. Yeah. >> Okay. So, this is just like connecting to rinky. So, all this signing will be on a on a test net, right? So, we are not going to send like real e. Um, so let's well let's get some money first, right? Uh maybe let's have it just like let's comment out the signaturebased stuff and let's have it uh report the balance and then we'll see that the balance is zero

right now. And then we can go to the the faucet and >> balance. And this is a >> so maybe you're writing a script that has a local pneumonic. Don't let's say let's say we're going to write a bot and when we send it money it needs to forward that money on or maybe split it. How about whenever this guy receives money it splits it between all three of our addresses or something like that. Right? So we're going to create a script. We don't want to copy paste in some other uh uh private key or pneumonic from someone else. We we want to generate one on this box and use it as this this uh signer and then its job will be to check its balance and then if

it has some balance send it on or something like that. >> Okay. So what is happening? Um machine provider maybe we have to wait here and wait here >> maybe not sure. Let's see. >> Nope. >> Uh maybe you need to go to serer.provider.getbalance or something like that. >> Oh that might be it. And then and and then does get balance need to have the signer's address.

>> Is that right? I I have no idea. Let's see what happens. >> Yeah. >> Okay. >> Uh so yeah, I think we so in this case, I think you want to connect the serer to a provider to get the signer to be able to send a transaction. But if we're just asking the balance, I think we want to just do provider.getbalance, right? Like I don't think we even need to. Yeah. Yep. >> Okay. >> Let's try that. >> Because signers and provider Yeah, that works. Signers and providers are different. A signer can do things like send a transaction. A provider can do things like get the balance.

>> Let's for Okay, >> nice. So it should be zero, right? >> Yep. >> Yep. Okay. Now let's hit the faucet. Awesome. >> So where is the the address? Somewhere here. Yeah, this is one. And sometimes these faucets aren't working. You have to go to multiple faucets. Like the fact that it's on a test net means it can get attacked.

There's there's certain uh different faucets that require like different socials be put in the paradigm. I think paradigm is one of the faucets. >> Yeah, >> that's really good. If you just search paradigm faucet, but you've got it and we've got a rinkabby transaction on the way. Let's see if our wallet detects a new balance. So, say this is some script running on some machine and every minute it runs. All right. So now it's detected a balance. Let's you want to actually like sign a transaction and send it out then.

Is that right? >> So this is this is the other this is where the signer comes in. Not just signing a message but actually sending a transaction right? >> Let's let's do it. That's a good way to close the day. >> Okay. So now we have the signer here and we can do send transaction, right? >> Oo. And yeah, I I think we will go deeper into this like the maybe tomorrow. >> This is a preview. Yeah, >> this is a preview, right? So, who are we who are we sending to? I mean to Sanford. Maybe >> we can go to Sanford. Yeah, sure.

>> So, not sure if this is going to allow having an ENS here. What do you think? >> Let's try it. Let's try it. That's a great thing to test. some for this and then >> and let's send him 10% of our balance. That's your that's your challenge here. >> Okay. >> You'll have to do some math in here. Yeah. >> But that's good. Like formatting these values, doing math on them, like that's something you're gonna have to do right away. >> So, let's have my balance here. And this is going to be a big number, right? as we talked about and um let's here

>> got an extra parenthesy there. Nice. >> Okay. So now um what I want to do is send you say like 10% of this. >> Yeah. Yeah. Yeah. >> So it's to be like my balance. I think it's div div. >> Yep. And uh >> in this in this case you could do a big number, right? You could do a new big number and divide it by 10. >> Yes. So >> yeah, >> in this case it's >> in this case that big number thing would have worked >> from I'm not sure if it's value >> 10.

>> I get like this, >> right? >> Let's see what happens here. I don't know. Let's find out. >> Okay, >> maybe we should even like before we send it like output it to make sure it's like the right number. I don't know. Let's we we could test it in prod too. It'll either send we'll see what it sends. >> So let's await for this. But um yeah, one thing is that when you do the await here, when the code reach this that doesn't mean that the transaction is done, that the transaction is mined. That only means that the transaction has been sent to the main poolool, right? So and you also you already have like info of the that has all of that. But if you want to really wait until the

transaction is mine, I think you have to do something like tx wait. I think >> let's put some Yeah, let's do it. And I think you await that. Oh, you are you are awaiting it. So maybe put a console log above that and console that the transaction is in the mim pool and here's the transaction >> and then do another console log after that transaction confirmed or something like that. Right. >> Yeah. like confirm. Yeah. >> Yeah. Perfect. Or mind or something. Yeah, that should do it. >> And maybe do you want to print something about the transaction? I don't know.

>> Yeah. >> What is Do you know any of the properties like hash or >> uh I think that Yeah, the hash is the most important part, right? Let's just let's output that. This is good. Let's print Let's print everything and see what's >> Let's ship it. Let's ship it. Let's see what it does. >> Okay. Okay. I think this is going to break but let's see. unsupported operation >> machine provider. >> Oh, did you connect? >> Yeah.

>> Yep. Okay. >> Let me wait once you >> just in case. >> Nope. It'd be provider.t transaction which is really weird. I think maybe we need to use the signer to sign the transaction and the provider to send the transaction. >> Or let's try. Okay, this worked. No. Oh. Oh, yeah.

This is working now. I don't know. So it seems that when you Oh, maybe disconnect just returns something and have to be like ser equals to >> sign. >> Do Yeah, maybe maybe it creates a new ser. Yep. >> Because when I pass the provider Okay. >> So it seems that that ENS name >> it doesn't like our name Sanford Stout. >> Darn it. this. So I mean but the the good thing is that we know how to convert back, right? I mean we know how to >> let's grab that from the other file or grab it from Yep.

>> Well, >> so this would be Sanford's address equals >> the resolve. >> This would be provider. Uh this is resolve name, right? Yeah. >> Yeah. Like this. >> It might be lookup address. I can't remember which one is which. I we'll find out. Trial and error. This is how we'll find out. >> I think it result Yeah. >> Let's try that and see what happens. >> Okay. >> We may even want a console log on line 30 that says like we're sending X amount to Yeah.

>> Sending if to >> Yeah. And then paste that address in. There we go. Let's see what happens. >> Let's see. Uh Oh my god. Oh my god. sending ETH to null. Yeah. So maybe I think it's lookup not resolve. >> H okay. But is it this is on the mele right? I mean >> yeah no resolve name should give you Yeah. No you did it right. Resolve name provider. Is it not Sanfordst Stouteth?

>> Oh. >> Oh it's on Rinkabe. We're on freaking rinkabe. We have to set up a mainet provider, resolve it on mainnet, and then get the address. It's the same thing we were mad about earlier. See, this is if you're a brand new programmer and you got to this point, you would be like, "It's not doing what I think it's supposed to do." >> Yes. >> Okay. So, let's do So, this is a rink if you're right. Right. And this is um Winky Hi there. This >> Yep. No, this is really good. This is good to show that you like if you your

app is going to have this. Your app is going to have a mainet provider so it can resolve ENS and then you may have some L2 that you're talking to or whatever network you're deploying to and it'll be a second provider and you'll need to use your mainet provider to look up all your ENS stuff but you'll need to use your normal provider to ship transactions to whatever network you're talking to. >> So this balance this balance is rinky because we want >> balance we want to connect the signer to the rink provider. >> Yeah. But we want to check Sanford's address on mainet.

>> Y >> hooray. This is some complicated stuff. This is why we do this. Like easy. Just go write a script. It's hard. There's more to it. >> I'm just wondering what happened here, you know, because the we send a transaction. Uh >> let's see. So if you send an address to no one, it's actually deploying a contract, right? If you scroll up, is the two address empty? Yeah, I think what it does is it looks at the data field and tries to deploy it as a contract maybe. I don't even know. Is it on chain? Did it happen? We could go and inspect it.

>> Yes. >> Yeah. Contract creation. It deployed a contract. >> Yeah. >> Yes. We just created a contract on accident by looking up the address and having a null to So, what's the If we go look at that transaction a little closer, does it have like the bite code of the keep? Yeah. open that up further. I mean, I think you have to have Wow. I don't know. There's there's stuff about like I don't know what's going on in terms of if the EVM respects that as an actual contract or not because it doesn't. There's no bite code. Like if you were to call does it have bite code, there's like a there's like an is contract function in solidity that checks to see if there's code at that

location. It seems like that would be false in this case >> and the is contract would actually fail because there's not bite code there. That's That's for another day. That's for another day. We just did some weird though. >> I think there will be like millions of contracts like this, right? Like people like sending >> weird empty. Yep. >> Okay. Okay. >> So, so now let's see if it works. >> So, now we want to go to mainet, get the mainet address, but then on rinkabe make the transaction. There we're sending ETH to Sanford's address on Rinkabe.

Yeah. >> And how much ETH did we send? >> It's 0.1, right? >> Roughly 10% of our value, right? >> Yep. >> This would be I mean because we the the balance was uh 08. So So let's see. I mean this is confirmed. So it should be here. >> Can we run it again and see that it like blocks on the Can we just do do the whole just up and enter? Just run that thing again. It should block for a little bit while it's waiting for the trans because we have two waits, right?

We have the awaiting the transaction at the start and then confirm transaction. It looks like it goes all the way to confirmed right away and it shouldn't, right? It should wait. >> No, no, but but it took some time, right? >> Let's watch it again. Yeah, it should take about 15 seconds or so. >> Yeah, but this is just the transaction. >> Okay, sending ETH. So, right at this point. >> Yes, but this is waiting. This is waiting. >> Oh, there it is. So, now it's in the me pool. >> Yes. >> Yeah. Okay. And now now it's confirmed. Okay, so those are the the steps. It's like >> packaging up the thing and sending it to the MIMP pool. Okay, the first await it's in the mim pool. And then the second one is it's mined into the block.

Awesome. We did it. >> Great work. >> And there we go. We actually sent some point. Yeah, there we go. >> Yeah. >> And are we sending 10%. We should check to see if it's the right amount. Is it right? Okay, cool. >> Awesome. And this is Sanford, right? Yes. >> Yes, we did it. Sanford has some rinkovie now. Awesome. >> Cool. >> The one one other preview I wanted to give, if I could steal the screen for a second to show uh my uh script. Boop. Okay. Uh looking so I just I did the same thing you did. This is the old script. This is the providers. Uh what I want to show is how much faster it is.

So this is the only difference here. I've got uh I'm talking to this node right here, this Nethermind uh nethermind address, right? So, it's a local IP address and then on port 8545. But remember how long that was taking to look up the different addresses and give you that information back and like what the block number is or like what my balance is. Watch how fast this is. Uh when you're talking to your own node, boop, it's way faster, right? So say say you wanted to get like thousands of balances, right? You you wouldn't be able to do that by asking Infura, you'd want to be able to have your own node

running where it has the whole state of the blockchain. It's talking peer-to-peer to everyone and you're asking it for a lot of this information instead of going out to a server and coming back. I just wanted to show that off there, too. Preview coming soon. You'll be running your own node and talking to it and building indexers and to talk to your apps and so much more stuff. Thank you, Carlos, for the great introduction to descripting. I'm excited for week two. >> Yeah. >> Yeah, that was like such a great intro. I I think I learned a lot of stuff which I didn't know before as well. I got the rinkb mainet part a bit later than you guys, but I got that.

>> It's all the gotchas and the weird things. like I'm glad we went through those and like ran into those problems because there are things that like your your brain glazes over and says of course that's just going to work. But then when you actually try to prove it to yourself and it doesn't work, it's a whole different ballgame. And I think that that's it's good. Like you as a developer at home take the time to prove it to yourself and copy paste some of these things and prove you know these these blind spots are are here and they're everywhere and you've got to cover these blind spots by just trying new things and see what happens. And we will also get into testing this week. So we can test our scripts on our smart contracts with a nice way to you know to make sure that you are not messing up

anything. >> Awesome. All right. I'll see you guys for the next one. Thanks everyone. See you later. Bye. Right.

Related talks