Basically, we deploy it with an initial value, we can read the value, and then we can update the value. So when you think of CRUD, create, read, update, delete, you can't really delete in blockchain, because every interaction is like saved forever. But we can update and we can create and we can read. Alright, so now that we understand what's going on there, we're going to go ahead and close this out. And we'll go jump back into our tutorial here. And we can continue on.
So what we want to do next is compile our smart contract into the ABI or the application binary interface. And to do that, we can basically use hard hat again. And all we need to do is run NPX hard hat compile. This, this command is going to look into our hard hat config and look for the actual folder where we want to create these artifacts. And we set that artifacts folder to be SRC slash artifacts. So after we run this program, we should see a new folder show up there. So if I go back to my terminal, and I run NPX hard hat compile from the root of the project. Now look inside my source directory, I should now see this new folder called artifacts. And indeed, we see that there. And, and the contracts, we're going to see basically, these two folder, I mean, these two files, we don't really need to mess with or anything. But these are the ABI's. Actually, this one is ABI. It's basically some JSON that kind of describes what's going on. And we can basically import that we never really need to open that and look at it just kind of want to show you what's there. So now that we've compiled our, our contract, we can now consider starting to maybe like interact with it.
So we need to think about interactions with a blockchain a lot differently than you might think of interactions with a typical database. Because when you write data to a database, you're typically going to be using some type of application that is hosted on AWS, or something like that. You know, whatever super base and the person that deployed that program is paying for that hosting service. I think the main fundamental difference is for the most part, when you're running, or you're interacting with a blockchain network, that the operations that happen on chain have to be paid for at the time of that operation happening. Now, sometimes you actually see this implemented on the server somewhere where they basically have a private key, and you're able to basically just call, you know, a back end, and they're doing it that way. But most of the time, you're actually going to be interacting with it and paying for this transaction yourself. Now, these transactions can run anywhere from a fraction of a penny, like when we're interacting with Solana, or are we've, or you're going to be working with something like aetherium, where it's kind of expensive right now. And I think that the reason that you're seeing a limited type of application being built on aetherium is because of how limited you are right now, for those types of payments. So if you're going to be doing some type of decentralized finance stuff, where you're transacting, you know, hundreds of dollars, it might make sense to pay a few dollars for a transaction. But let's say you want to just do something really basic. Anything over a couple of dollars is doesn't make a lot of sense. So I think that's why you're seeing, you know, all types of new blockchain protocols that are more scalable, and maybe less expensive and stuff come out for different other types of use cases. And you're also, you know, needing to understand maybe that the way that you build one of these applications is going to be a lot different. You might only store very important information on chain. And then you might use some other type of decentralized storage that's free for other types of stuff. So that's just all fundamental, like things to think about as we're going about this. But basically, what we want to do now is we want to basically deploy our contract to a local network. So we can deploy to the aetherium main network, or we can also deploy to one of these test networks that are out there. But to do that, we need to go ahead and find aetherium, you know, test aetherium and send it to our wallet. And it's kind of, you know, a bunch of steps, though the most the, you know, the best way is to deploy it to a local network. And the best way I would say for local testing and development is to use a local network. And we can actually create a local network just by running NPX hard hat node. So I can just copy this, and I'm going to split my terminal into a couple of new windows, because we're going to need to run multiple windows. And I'm just going to clear this out. And the first thing I want to do is go ahead and create a local network, run a local aetherium node. And I can do that by running NPX hard hat node. And this will go ahead and start a local test network, a local aetherium node, and it will give me 19 test accounts. And each one of these accounts I can actually import into my metamask wallet. And I'm starting off with 10,000, at the 10,000 ETH, which means I can have some money to test out my program with. Because when I write a transaction, I'm going to need to pay some type of ETH to write to the block to the network. And now I have 10,000 ETH spread or multiplied by 20 on 20 different accounts that I can use. Alright, so what we're going to do next is go back to our tutorial. And we're going to go ahead and deploy our program to that test network. So to do that, we have a script located at scripts slash sample script.js. So let's go ahead and take a look at that. And I'm going to delete all of the comments and stuff to make this a little bit more easy to read. Alright, so not a whole lot going on here. There's really only four lines of code, or really three lines of code that we need to deploy this. First of all, we're getting a reference to the contract by saying ethers dot get contract factory and paste pasting in the string for the name of the contract. Now we're able to do this because in our hard hat config, we basically are setting the path for the artifacts. And then this is going to look in that path and it's going to find the artifact for the greeter. And this is essentially going to be getting the ABI and making it available right here in this line of code. The next function that we're going to call is greeter dot deploy. And this basically now that we have a reference to this contract, we can call deploy and then we can pass in the constructor argument. In our case, we want to set that initial value for greeting. So this could be whatever. So I could say react. London or something like that. And this will be the initial value for our program.
Comments