Part 0 - Solidity development environment

This tutorial would provides step-by-step guidance on how to set up a Solidity development environment with Hardhat and npm or yarn

To develop Solidity smart contracts, we need to have Node.js installed on our system. This is necessary for a variety of purposes, such as deploying the smart contracts, testing them, running local blockchains, and more.

  1. Install Node.js:

You can download the latest version of Node.js from the official website: https://nodejs.org/en/download/.

  1. Install Yarn (OPTIONAL):

Once Node.js is installed, you can use one of the following methods to install Yarn:

a. Using npm:

Open a terminal or command prompt and run the following command:

npm install -g yarn

b. Using Homebrew (MacOS only):

If you're using a MacOS, you can use Homebrew to install Yarn. Open a terminal and run the following command:

brew install yarn

c. Using Chocolatey (Windows only):

If you're using a Windows system, you can use Chocolatey to install Yarn. Open a command prompt with administrative privileges and run the following command:

choco install yarn

3. Verify Yarn installation:

Once Yarn is installed, you can verify the installation by running the following command in a terminal or command prompt:

yarn --version

This command should output the version nqumber of Yarn that you just installed. If the output shows an error or an unexpected result, try reinstalling Yarn or check the documentation for further troubleshooting steps.

Yarn

  1. How to Install VS Code:

a. Go to the official website of Visual Studio Code (https://code.visualstudio.com/).

b. Click on the "Download for Windows/Mac/Linux" button depending on your operating system.

VSCode

c. Wait for the download to complete.

d. Once the download is complete, open the downloaded file.

e. Follow the installation wizard, accept the license agreement and choose the installation folder.

  1. How to create a new folder for a project called "HelloNFTWorld":

a. Open Visual Studio Code.

b. Click on "File" in the top-left corner of the window.

c. Click on "Open Folder" from the drop-down menu.

d. Choose a location where you want to create a new folder.

e. Click on "New Folder" to create a new folder.

New folder

f. Name the folder "HelloNFTWorld".

g. Click on "Select Folder" to open the folder in Visual Studio Code.

  1. How to Install Hardhat as a dev dependency using Yarn:

a. Open the terminal in Visual Studio Code, it is located in the Terminal submenu

VSCode terminal

b. Navigate to the "HelloNFTWorld" folder by typing cd HelloNFTWorld.

c. Type the following command to initialize the package.json file:

yarn init -y

New project

A package.json file should have appeared in your working directory

d. Type the following command to install hardhat:

yarn add --dev hardhat

Hardhat

e. Wait for the installation to complete.

Hardhat

  1. How to using Hardhat initialize a new TypeScript project:

a. In the terminal, type the following command:

yarn hardhat

b. Follow the instructions on the terminal to set up the Hardhat project.

Hardhat + Typescript

c. When asked to choose a preset, select "TypeScript".

New Project initialization

d. Follow the rest of the instructions on the terminal to initialize the TypeScript project.

e. Once the initialization is complete, you can start working on your project in Visual Studio Code.