Hardhat is a development environment and framework for building, testing, deploying, and debugging Ethereum smart contracts.
It's like a Swiss Army Knife for smart contract devs.
Think of it like this:
| Tool | What itβs like |
|---|---|
| Hardhat | π VS Code + Node + Git combined for blockchain |
| Solidity | π¬ The programming language |
| Ethers.js | π‘ Talks to Ethereum network |
| Hardhat Network | π§ͺ Fake Ethereum node just for you |
| Feature | Purpose |
|---|---|
| Compile contracts | Converts Solidity code to bytecode/ABI |
| Deploy contracts | Sends your contracts to Ethereum (or local) |
| Run tests | Mocha + Chai powered testing framework |
| Create local blockchain | A fake, super-fast Ethereum chain (like a sandbox) |
| Console & scripts | Test interactively or automate workflows |
| Debug & stack traces | Helps trace errors in your contracts |
| Plugins (like ethers, waffle, gas reporter, etc.) | Extend functionality easily |
When you run npx hardhat, it creates this:
my-project/
β
βββ contracts/ <-- Your Solidity contracts
β βββ MyContract.sol
β
βββ Ignition/Modules <-- Manual deployment or automation scripts
β βββ deploy.js
β
βββ test/ <-- Mocha/Chai-based tests
β βββ myContractTest.js
β
βββ hardhat.config.js <-- Project configuration (compiler, networks, etc.)
Hardhat spins up a local Ethereum blockchain: