Skip to content

Prerequisites for Truffle, Hardhat and Foundry Labs

View the Full Course Now

Weather you are developing with Truffle, Hardhat or Foundry, you need a few tools first. That is Nodejs, Git and if you want to follow along with the Labs here, VSCode.

If you have those things already installed, then skip to the next lecture, otherwise stay on, we're making your system dev-ready.

Install Prerequisites

Truffle and Hardhat are JavaScript based tools. Foundry is a totally different beast, installed also globally, but mainly uses git submodules. For Truffle and Hardhat you need npm, the node package manager. You will also need Git, as truffle will download the web3js library and try to compile a few files. If you're on Windows, for Foundry I strongly suggest to download a WSL2 based distribution, such as Ubuntu. I'm going with a slightly older distribution here, Ubuntu 20.04, but anything should really do the trick.

Let's check first if NPM/Git is installed...

Open a terminal/PowerShell and see if they are installed:

node -v
npm -v
git --version

Git Version

Should bring up version numbers. If you get an error that its not installed, then install them first.

Windows vs Linux vs MacOS

Of course, there are differences between operating systems. To make everything "as equal" as possible, I will use an Ubuntu 20.04 in a WSL2 environment on Windows. This way everyone should be able to follow along and the differences between Mac, Linux and Windows should be very minimal.

You can, however, technically work on a normal windows environment with PowerShell - it should just work out of the box. Be careful with forward/backward slashes in directory names. If you want, you can also download WSL2 and Ubuntu from the windows store.

Info

For some of the commands you will need administrator privileges. If you are running this on a corporate laptop with a secured down environment, some commands might not work correctly. Please consult your IT department for help.

If you have never worked with NodeJs and/or don't have Nodejs and the necessary tools installed, then lets install them first. Otherwise feel free to skip to the next lab.

On Windows I can wholeheartedly recommend the Windows Terminal, which supports multi tabs and so on.

NodeJS

Head over to https://nodejs.org/en/ and download and install NodeJS. It's a prerequisite to install and truffle and hardhat and work with both. At the time of writing the Go-To version of NodeJS is 16.17.0 LTS.

If you are on Windows, then make sure you check this checkbox, as it will also install all the build tools and compilers needed to install truffle and web3js, which will be compiled when we install it:

Nodejs install dialog

Info

In earlier versions of NodeJS it was necessary to run something like npm install --global windows-build-tools@4.0.0, which isn't necessary anymore. The build tools can be installed directly during the setup routine.

Install NodeJS first before continuing with the course.

For Ubuntu you can install the right version directly from the shell script:

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -

Git

You will also need to have Git installed on your system. Git is a version control system, which will allow truffle and foundry to download packages needed to run. If you have any web development background, its very likely you already have git installed on your system, but if not, then you also need to Download and Install Git.

Download it and install it, just follow the wizard. There are no special options, the sensible defaults should work on all systems.

Visual Studio Code

In the following lectures I am using VS Code from Microsoft. Its available for Windows, Linux and MacOS. It also integrates nicely into WSL2, should you want to use it on Windows. You can Download and Install VSCode from the official website. Again, just follow the installer.

Visual Studio Code Plugins

I can further recommend the following plugins, which I use daily:

I personally use Solidity Visual Developer, and I am pretty happy with it. But a lot of other people recommend Solidity, by Juan Blanco. Both come with Syntax Highlighting and that's more than enough for now.

What I also recommend is the DotENV for environment files.

Theme wise, I am using the Dracula Theme, but that's just my personal flavor.

And that's actually enough to get started.