The One Question bounty closes Thursday 10 December.

Join in
We Them Media logo We Them Media Support us

Web3bridge Students (cohort 11) Share What They’ve Learned: Deploying a Smart-Contract

The picture loads from YouTube. The player loads only when you press Play. Turn on captions in the player if you need them.

Web3 Bridge Cohort 11 students explain deploying smart contracts to a test network with Hardhat and Foundry. They cover setup, compiling, keeping node provider and wallet keys in environment variables, deploying to Sepolia, and verifying the contract on Etherscan.

Not by We Them Media Channel: Web3Bridge. Published Tuesday 15 October 2024.

Titles are the owner’s. It plays from their channel.

Transcript

This transcript may contain errors. This video belongs to Web3Bridge. Letters mark each change of speaker.

These are the speakers’ own words. We have not checked their claims.

0:00 A: This video is brought to you by Lix, your official sponsors for Cohort 11.

0:05 B: My team and I will be talking about deploying the smart contract to a test network, and I'll be speaking on deploying using Hardhat.

0:13 C: Why I think Foundry is exciting is because it lets you write your scripts with Solidity, and yeah, why not write your contract and then your script also with Solidity? I think that makes it That makes it really fun.

0:27 D: So when you're done with all that deployment, you need to verify if it's actually there, and also you need verification for other people to also see that, yeah, this is my work on blockchain.

0:39 B: For you to deploy a contract, you must have been ready, you must have tested all the functions, make sure everything is working well and all the codes written very well to to optimize gas and everything. Now, it's always better to test your codes on the Remix IDE before deploying it to make sure everything is working well. Now, for you to deploy, you must have Hardhat installed on your machine. And when you have Hardhat, you initialize the Hardhat environment. So you create a project. Now when you're done creating a project, you compile your project using npm hardhat compile. Now this creates an artifacts folder, and in the artifacts folder you have your bytecodes and your ABI. That is what you eventually use to interact with your front end of the application. With your Node RPC URL and your MetaMask private key, use that to create an environment where you use to deploy the network on your test network. It can be Sepolia, it can be any other test network that you would like to use.

2:00 C: Your process of deploying with Foundry has to do with you setting up your environment on your PC where you could go on the documentation, on the Foundry documentation online, And then you simply just follow the process, the process that was there. I think it's really well documented. I really just ran through the process there where you have to initialize Foundry on your PC and then start a new project and then also initialize Foundry in the project where you, in the folder where you've created your project. And from there on, the folder structure is literally kind of different from how you it'll look on Foundry, on, um, Hardhat. I mean, Hardhat is inspired by, I would say, JavaScript, cuz you still have your node_modules and things like that. But whereas on Foundry, you just have your, you just have your source folder, and then they also have a lib, which represents our node_modules folder on JavaScript. Now this lib, This lib folder contains your dependencies. So, um, any dependency that is added to Foundry appears in your lib folder. And yeah, once you have your folder structure and everything set up, all you need to do is run pod build to compile your code. And once your code is compiled, what you need to do is, um, go to Alchemy, get your API key, and also go to Etherscan, get your API key. You have to, um, add all of these in your config folder. And then once you have those keys, I think it's important for you to put them in an environment variable so that you don't go pushing your keys or deploying your keys because those keys are supposed to be private to you and things and stuff like that. You don't want to deploy them for everyone to see. So you have to add them to an environment variable with your .gitignore. And stuff like that. Once you've compiled your code, all you need to do is to run your, um, your build, your build command. Once, once it has built your files for you, yeah, there's also a command you use to deploy your scripts. And once you've deployed that, I think you're very much good to go. Once your deployment runs successfully, that's where the joy kicks in.

4:21 D: Ada, I'd say accepts 2 objects, the network and also the Etherscan. So for network, you have 2 properties in the network. You have the URL and the address private key. In URL, you can get it from Alchemy. Alchemy is a node that runs your smart contracts on the blockchain. We use the Sepolia network for running our Um, for deploying our smart contract. And you get your URL from Alchemy by signing in, opening an application app and signing in, getting the URL endpoints. So when you get that, you put it in your URL. Also your private key, we use MetaMask address. You get your private key from MetaMask and then you also add it to your work. Why for Etherscan? You open and you log into your Etherscan and get in, um, and open an app and get the API key also there. So when you do that, you practically run following the command on your AddArt documentation. You run your script and then you check- immediately you're done running, you check Etherscan and you see your work verified. And with- when it's verified, you have a verification sign on your work that yes, it's tested and verified on the network, on the blockchain. For Foundry, Foundry is a lightweight ID where it's compiled already for you, so you don't need to have the configuration file. All you need to do is just to run a command line verification, putting your private key and then the path to your work, and you run the command and you're verified on with Foundry.

6:08 C: For more of our weekly videos, please like, subscribe, and share.

More from this hub

Something wrong, or a video you want off this page? Write to wethem.xyz@gmail.com and it is fixed or taken down within 48 hours.