$ show NomicFoundation/hardhat
Hardhat is a professional Ethereum smart-contract development environment, implemented as a large TypeScript monorepo. In production it operates as a CLI and programmatic framework that compiles Solidity, runs tests against local or remote networks, deploys contracts, verifies source code on block explorers, and manages project secrets and hardware-wallet signing. The core `hardhat` package provides a task runner, plugin system (`definePlugin`), hook handlers, config loading, and a Hardhat Runtime Environment, while companion packages add viem/ethers client integration, chai matchers, the Ignition declarative deployment engine, verification against Etherscan/Blockscout/Sourcify, Mocha and node:test runners, Foundry remapping support, coverage, gas analytics, and alternative Slang/Solx compiler backends. The architecture is a modular, hook-driven monorepo of 30+ packages. The core exposes lifecycle hooks for config, network, HRE, Solidity, and testing; plugins register tasks, global options, and hook handlers that compose through `next()` chains. Ignition-core implements a journal-based deployment state machine with reconciliation, execution strategies, and nonce management, making deployments resumable and auditable. The network layer abstracts JSON-RPC providers over HTTP and EDR-backed simulated networks, with request handlers for gas estimation, account management, and chain validation. Entry points include `packages/hardhat/src/cli.ts`, `packages/hardhat/src/hre.ts`, `packages/hardhat/src/config.ts`, and `packages/ignition-core/src/deploy.ts`. The codebase is well-engineered and heavily tested, with fixture projects, CI workflows, changesets, e2e scenarios against real-world projects, and benchmark infrastructure. It is current with Node 24 and modern TypeScript/ESM patterns. Notable minor issues include duplicated helper code across packages, hand-maintained chain/explorer mappings and hardfork lists, and some fragile workarounds around third-party CJS/ESM interop. Overall, it is a strong, actively maintained developer-tooling codebase with several genuinely reusable internal components.
The LLM identified 4 files worth highlighting for reuse:
Self-contained Solidity source dependency graph implementation with root/dependency tracking, remapping collection, subgraph extraction, graph merging, and deterministic JSON serialization. It enforces uniqueness by resolved file and input source name, and uses invariant assertions for internal consistency. This is safely extractable into any compiler/build tool that must model source-file dependency relationships.
A dependency-free semver parser and comparator that implements the semver spec without pulling in node-semver. It is used throughout the monorepo for Solidity compiler version checks and package version resolution. The module is isolated, well-tested, and could be extracted into any Node/JS project needing lightweight semver handling.
Reusable Zod-based validation combinators for user-facing configuration: conditional union types, incompatible field detection, sensitive string schemas, and a `validateUserConfigZodType` helper that surfaces actionable configuration errors. Plugin authors can adopt this pattern outside Hardhat to validate nested tool configuration with rich, user-friendly messages.
Core helpers for replaying a deployment journal into an immutable deployment state. This demonstrates a clean event-sourcing pattern where journal messages are reduced into state snapshots, making the deployment process resumable and auditable. The reducer/replay pattern is generic and can inspire similar state-machine implementations in other transactional workflow systems.