Setting up your dev environment

Get Hardhat, a local node, and VS Code configured so you can write and test contracts locally.

The tools you need

The Solidity development ecosystem has standardized around a few core tools. You'll need Node.js, a package manager (npm or yarn), and one of two frameworks: Hardhat or Foundry. These notes use Hardhat because it's JavaScript-first and easier to integrate with frontend tooling.

Install Node.js

Use nvm (Node Version Manager) to install and manage Node.js versions. This gives you flexibility when different projects need different versions.

bash
# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# Install and use Node 20
nvm install 20
nvm use 20

Create a Hardhat project

Hardhat is the most widely used Solidity development framework. It handles compilation, testing, local node simulation, and deployment scripts.

bash
mkdir my-solidity-project
cd my-solidity-project
npm init -y
npm install --save-dev hardhat

# Initialize Hardhat
npx hardhat init

When prompted, choose "Create a JavaScript project" (or TypeScript if you prefer). Hardhat will scaffold the following structure:

bash
my-solidity-project/
├── contracts/          # Your .sol files go here
├── ignition/modules/   # Deployment scripts
├── test/               # Test files (Mocha + Chai)
├── hardhat.config.js   # Configuration
└── package.json

Install the Solidity VS Code extension

The official Solidity extension for VS Code (by Nomic Foundation, the team behind Hardhat) gives you syntax highlighting, inline error checking, and go-to-definition support.

Open VS Code, go to Extensions, search for "Solidity" and install the one by Nomic Foundation.

Compile your first contract

Hardhat ships with a sample contract. To compile it, run:

bash
npx hardhat compile

You'll see output confirming the contract compiled successfully. The compiled artifacts (ABI + bytecode) land in the artifacts/ directory.

Run a local node

Hardhat includes a built-in Ethereum node for local development. It starts with 20 pre-funded accounts and fast block times.

bash
npx hardhat node

Keep this running in a terminal tab while you develop. You can deploy contracts and send transactions to it without spending real ETH.

Run the tests

bash
npx hardhat test

You're ready. Let's write some contracts.

←   Why Solidity?Your first contract   →