Rahul Rathod
Raaulc's Blog

Raaulc's Blog

2. Get up to Set up

2. Get up to Set up

Rahul Rathod's photo
Rahul Rathod
·Oct 2, 2021·

2 min read

Let's set up a local Ethereum network in our machine.

Wait, What will this do? It will compile and test our smart-contract code locally.

Okay, but what is a smart contract? The smart contract is Some code that lives on the blockchain, and blockchain is a kind of open house where anyone can live. So our smart contract will live in the house of blockchain-like many other smart contracts. This house called blockchain is maintained by some staff who are getting paid for it. We call them miners.

Enough, Let's start.

We are going to use HardHat for compiling and testing smart contracts locally. Considering you have node setup already we will run some commands here.

We will install Hardhat using npm. Open the terminal and run these commands.

mkdir hello-nft
cd hello-nft
npm init -y
npm install --save-dev hardhat

In the same directory where you installed Hardhat run:

npx hardhat

Select Create an empty hardhat.config.js with your keyboard and hit enter.

$ npx hardhat
888    888                      888 888               888
888    888                      888 888               888
888    888                      888 888               888
8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888
888    888     "88b 888P"  d88" 888 888 "88b     "88b 888
888    888 .d888888 888    888  888 888  888 .d888888 888
888    888 888  888 888    Y88b 888 888  888 888  888 Y88b.
888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888

Welcome to Hardhat v2.0.0

? What do you want to do? 
  Create a sample project
 Create an empty hardhat.config.js
  Quit

Choose the option to create a sample project. Keep pressing enter for all next steps until it creates the project for you.

Now run this command,

npx hardhat run scripts/sample-script.js

it will show something like,

Screenshot 2021-10-02 at 5.29.10 AM.png

Congratulations, the local environment for the blockchain is setup now.

In the next blog, we will write our first code for solidity.

 
Share this