Setting Full Development Environment For Solidity

Çağatay Akkaş
Developer Community
6 min readJan 7, 2023

Selam everyone. In every coding language seting up the environment is one of the hardest steps. However for Solidity maybe its the hardest part. So now we will go step by step and try to make perfect environment for us.

  1. Downloading Visual Studio Code

Go to https://code.visualstudio.com/download . Select the right option for your computer.

Select all boxes and click next.

Visual Studio Code will open. For installing other tools without any error open Visual Studio Code as administor.

2. Node.js

For downloading go to https://nodejs.org/en/download/ . After that click LTS which stands for long time support. And install the version you want.

After starting installation do not forget to select automatical installation.

After that, command prompt and Windows PowerShell screens will pop up. Click Enter button until it start installation.

After installation finished , open new terminal in Visual Studio Code.

And type:

wsl --install

if installation did not start and a WSL help text showed up. Type:

wsl --list --online

We will manually download these. For that in terminal type:

wsl --install -d <DistroName>
Example: wsl --install -d Ubuntu
Example: wsl --install -d Debian

After installations. Restart your computer. And re open Visual Studio Code. For checking did installation went correct in terminal type:

node --version

If you do not see this. Then for trouble shooting go to https://learn.microsoft.com/en-us/windows/wsl/install

3.Installing extensions

In Visual Studio Code we will use many extensions. For that click extensions icon

And type “Remote Development” in extension search area. And install extension.

After that click “ctrl + shift + p” keys at the same time for opening Command Palette or you can go to settings and open it manually.

For manually opening Command Palette

Type “wsl” in search area and select WSL: New WSL Window

And another window will open. And when you open terminal click arrow and open with Git Bash. Now we are ready for action.

Here if you are facing with error

Go to https://git-scm.com/download/win . And select the one which suitable for you.

Do not forget to select “Add a Git Bash Profile to Windows Terminal” option. And click next until installation finishes.

After installing. Open Command Palatte again with “ctrl+shift+p” or in settings. And type “select default” and open Terminal: Select Default Profile

And select Git Bash

Open new terminal and select Git Bash. And we are ready for our next step.

Now we will download nvm. For that in bash terminal type:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

And after that type:

source ~/.nvm/nvm.sh

To understand we installed correctly, open a new bash terminal and type:

nvm --version

After that, for installing Node.js for bash type(write the version you downloaded as LTS(long time support)):

nvm install 18.13.0

4.Using Hardhat

For installing hardhat type “hardhat” in extensions search area and download “Solidity” by Nomic Foundation.

After that open command palette and type “Preferences Open” and chose Open User Settings (JSON).

Your settings.json file can be empty or not but if not empty just put comma ( , ) and type:

"[solidity]":{
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
}

After that open settings with clicking bottom left icon and choosing settings option.

Then type “format on save” and select this option.

Now for compiling our code we will download Yarn packet manager.For installation. (Here you should open Visual Studio Code as administor)Type:

corepack enable

And for checking type:

yarn --version

And for compiling Solidity we will install solc. For that in bash terminal type:

yarn add solc

Now for compiling our code: For Javascript we will use “node filename.js” and for Solidity:

yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . nameOfFile.sol

But instead of writing this line everytime in package.json type:

"scripts": {
"compile": "yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . nameOfFile.sol"
}

With this when you type “yarn compile” it will compile your file.However there is even better way to do that. For second method type:

yarn init

And after writing project name click enter until all questiones finishes.And in bash terminal type:

yarn add --dev hardhat

And chose Javascript project.

After that type:

yarn add --dev @nomicfoundation/hardhat-toolbox @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan chai ethers hardhat-gas-reporter solidity-coverage @typechain/hardhat typechain @typechain/ethers-v5 @ethersproject/abi @ethersproject/providers

Now if we type:

yarn hardhat

we will see a list of actions:

Now time to use Hardhat.

For compiling -> yarn hardhat compile
For running scripts -> yarn hardhat run scripts/nameOfFile.js
For running scripts on networks
-> yarn hardhat run scripts/nameOfFile.js --network networkName (exp:hardhat)
Note: Here for using networks other than hardhat you need to specify them in hardhat.congfig.js

5. Prettier (optional)

Prettier is a code formatter working for many programming languages.For installing go to extensions and type Prettier and download extension.

and again in settings.json file (open from command palatte)

type:

"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}

You can also set Prettier as default formatter from opening settings and typing “default formatter” and chosing Prettier.

Thanks for reading this far. Hope it was beneficial for you. See you in the next one =)

--

--