Hardhat Installation

Create a directory called ‘hardhat’.

Launch the VS Code editor and access the terminal. Then, navigate to the hardhat directory.

Run the below command on terminal.

sudo npm install hardhat

After hardhat installed, we can initiate the project with below command.

npx hardhat init

The next step is to compile the project using the following command.

npx hardhat compile

If you encounter an error with the compile command, try running the following command first, then execute the compile command again.

npm install --save-dev @nomicfoundation/hardhat-toolbox

In order to initiate the test, use the below command.

npx hardhat test

You will see the test result as ‘9 passing’.

Deploying Smart Contract to the Network

To deploy the contract on the Hardhat local network, execute the command.

npx hardhat ignition deploy ./ignition/modules/Lock.js

Upon successful deployment, the deployment address will be displayed as the result.