hardhat
Develop, test, and deploy smart contracts
TLDR
List available subcommands (or create a new project if no configuration exists)
Compile the current project and build all artifacts
Run a user-defined script after compiling the project
Run Mocha tests
Run all given test files
Start a local Ethereum JSON-RPC node for development
Start a local Ethereum JSON-RPC node with a specific hostname and port
Clean the cache and all artifacts
SYNOPSIS
hardhat [GLOBAL OPTIONS] [<TASK>] [<TASK OPTIONS>]
PARAMETERS
--help, -h
Display help for the command
--version, -v
Print Hardhat version
--network <NETWORK>, -n
Select network (e.g., localhost, hardhat)
--verbose
Enable verbose logging
--quiet
Suppress non-error logs
--config-dir <DIR>
Custom config directory
--config <PATH>
Path to hardhat.config.js
--max-memory <MB>
Max memory for subprocesses
--show-stack-traces
Always show stack traces
--gas-reporter <FLAG>
Gas usage reporting (with plugin)
DESCRIPTION
Hardhat is a powerful Ethereum development environment designed to help developers compile, deploy, test, and debug smart contracts. It provides a local Ethereum network for fast iterations, automatic compilation of Solidity code, a built-in testing framework compatible with Mocha and Chai, stack trace parsing for better debugging, and a console for interactive contract interaction.
Key features include task runners for automation (e.g., deploy, verify), plugin ecosystem for extensibility (e.g., ethers.js, OpenZeppelin), network support for mainnet, testnets, and local nodes, and advanced scripting capabilities. Hardhat simplifies the development workflow with hot-reloading compilation and gas estimation. It's widely used in Web3 projects for its reliability and community support.
Installation requires Node.js; run npm install --save-dev hardhat to initialize a project with sample files.
CAVEATS
Requires Node.js (≥14) and npm. Not a native binary; run via npx hardhat or global install. Config file hardhat.config.js mandatory for tasks. Large projects may need memory tweaks.
COMMON TASKS
compile (Solidity compilation), test (run tests), console (REPL), run <script> (scripts), deploy (deployment tasks via plugins)
INSTALLATION
npm init -y && npm install --save-dev hardhat, then npx hardhat
CONFIG FILE
hardhat.config.js: Exports object with networks, solidity version, paths, mocha opts
HISTORY
Launched in 2020 by SmartCocoon as a flexible Ethereum dev tool. Acquired and open-sourced by Nomic Foundation in 2022, becoming a standard in Web3 development with active plugin ecosystem.


