Deploy a Solidity Smart Contract with Hardhat to a Local Ethereum Network

Share this video with your friends

Send Tweet

Now you need a way to keep a local network alive, deploy the smart contract there and then interact with it. You can think on this like a local web server. When you develop an API you have a local server running it so the client application can talk to it so you can develop and test, this is the same idea.

Head over to your terminal and run tthe following command.

$ npm run hardhat node

This will ramp up a local ethreum network using hardhat and will show in the console a set of accounts and private keys that can be used for testing pruposes.

These are 20 test accounts and addresses created for your. Each account is also rich! are loaded with 10000 ETH. (fake eth btw).

Right now this is just an empty blockchain. There are no blocks nor smart contracts on it. But you want to create a new block and put the smart contract that you just created there, for that you need to create a little script that will use ethers.js power to compile and deploy.