Hardhat vs Foundry in 2026: tests, fuzzing and deployment
Hardhat 3 now runs Foundry-compatible Solidity tests: what sets them apart in deployment, and an invariant campaign that passes while testing nothing.

Over the months, a smart contract repository accumulates three kinds of code besides the contracts: unit and integration tests, scripts that deploy and configure each network, and the code that connects those contracts to a TypeScript backend or frontend. Hardhat and Foundry are the two tools used to organize that work in EVM projects: they compile, run tests, start a local network and send deployments, and each one sets the language in which every part is written.
For years the comparison came down to the test language: JavaScript or TypeScript in Hardhat, Solidity in Foundry. Hardhat 3, released in August 2025, runs Solidity tests compatible with Foundry's and shares its default fuzzing and invariant settings, so that criterion no longer separates them. What decides today is where the rest of the repository lives: if deployment and integration are in TypeScript, Hardhat keeps them next to the tests; if the team operates with Solidity scripts and from the terminal, Foundry covers it with fewer moving parts.
Hardhat 3 and Foundry 1.x in November 2026
Hardhat released version 3.0.0 on 13 August 2025, and the latest stable release as of 8 November 2026 is 3.21.2, from 29 October. The 2.x line is still published on npm under the hh2 tag (2.29.1 dates from August 2026), so an older project can stay on it while it plans the migration. According to the Hardhat 3 what's new page, configuration becomes declarative and must be written as an ESM module, test runners become plugins (the Node.js runner is recommended), Solidity coverage is produced with the --coverage option, and the simulated network supports several chain types, with initial support for Ethereum Mainnet and OP Mainnet.
Foundry reached version 1.0 in February 2025, and its latest stable release is 1.9.0, from 2 November 2026; the nightly builds that appear daily in its repository are prereleases. The toolkit keeps its division of labor: Forge compiles, tests and runs scripts; Cast queries networks and sends transactions from the terminal; Anvil starts a local node; and Chisel is a Solidity REPL.
The same Solidity tests, with the same defaults
In Hardhat 3, a file is a Solidity test if it sits in the test/ folder or ends in .t.sol inside contracts/, and every function whose name starts with test runs as a case. The Solidity testing guide lets you install forge-std, inherit from its Test contract and use cheatcodes such as vm.prank, and it treats any test function with parameters as a fuzz test. A suite written with forge-std can move to Hardhat 3 without being translated into TypeScript, and it runs with hardhat test solidity alongside the integration tests of the same project.
Campaign settings match as well. Both tools run 256 cases per fuzz test, 256 sequences per invariant test group with 500 calls each, and up to 5,000 attempts to shrink a failing sequence to the shortest one that reproduces the error. In invariant tests, neither fails by default when a call reverts; in fuzz tests, Foundry does fail on a revert in a contract other than the test contract.
| Setting | Hardhat 3 | Foundry |
|---|---|---|
| Cases per fuzz test | fuzz.runs = 256 | [fuzz] runs = 256 |
| Sequences per invariant test group | invariant.runs = 256 | [invariant] runs = 256 |
| Calls per sequence | invariant.depth = 500 | [invariant] depth = 500 |
| Fail when a call reverts (invariants) | invariant.failOnRevert = false | [invariant] fail_on_revert = false |
| Attempts to shrink a failing sequence | invariant.shrinkRunLimit = 5000 | [invariant] shrink_run_limit = 5000 |
An invariant campaign that passes without testing withdrawals
Consider a hypothetical deposit contract with two functions, deposit and withdraw, and an accounting property: the sum of user balances equals the contract's total assets. The team writes an invariant test that calls those functions through a handler, an intermediate contract that picks the user and the amount for each call. If the handler passes withdraw a random amount across the full uint256 range, the chance that it does not exceed a test user's balance is negligible, and every withdrawal reverts.
With failOnRevert set to false, the default in both Hardhat 3 and Foundry, those reverts do not fail the campaign: the 256 sequences of 500 calls complete, the property holds at every check and the result shows green. The property holds because the state barely changes, not because withdraw is correct: a rounding error in withdraw would never execute. Foundry helps catch this because it collects per-function call metrics by default (show_metrics) and prints them in the report, and its invariant testing guide recommends constraining handler inputs with bound() instead of discarding them with vm.assume().
The fix is the same in both tools. The handler bounds the amount to the chosen user's balance with bound(), keeps its own count of effective calls per function, and the test requires that count to exceed a minimum before treating the property as checked. Once the handler only generates valid calls, enabling failOnRevert turns any unexpected revert into a visible failure. With the defaults, the same file passes under hardhat test solidity and under forge test if the handler is badly built: the tool runs the campaign, but it does not decide which part of the contract actually gets tested.
What does separate them: deployment, scripts and simulated networks
Deployment is where the two tools follow different models. Hardhat Ignition describes a deployment as a declarative TypeScript module, with parameters in a separate file, and stores a journal of every executed action in ignition/deployments/chain-<id>. If a deployment is interrupted, running it again with the same ID resumes from the last recorded step, and a new module can reference contracts from an earlier deployment.
In Foundry, a deployment is a Solidity script that inherits from Script. According to its deployment guide, forge script simulates execution against network state unless --broadcast is added, writes receipts to the broadcast/ folder and supports --resume to continue an interrupted broadcast; since version 1.8.4, resume state is stored in a .recovery.json file that must be kept until the deployment completes. Cast adds the ability to read a contract, decode calldata or send a transaction from the terminal without writing a script.
The difference matters depending on who operates the system afterwards. If the same team maintains a TypeScript backend that needs each network's addresses, ABIs and parameters, keeping them in the Hardhat project removes a synchronization step; the viem-based Hardhat 3 toolbox bundles Ignition, contract verification and a plugin that stores encrypted keys on disk. If the operator is a protocol team that deploys, queries and patches from the terminal, Foundry concentrates those tasks in binaries that do not depend on Node.js. Hardhat 3's chain-typed simulated networks add an argument for projects that deploy to OP Mainnet and want to reproduce that environment locally.
Keeping both tools in one repository
Before Hardhat 3, some repositories with TypeScript integration used Foundry for tests and Hardhat for deployment. With compatible tests in Hardhat 3, that split is no longer needed to write Solidity tests, and keeping both tools has a concrete cost: two compiler and optimizer configurations that must match, two ways of resolving dependencies and two artifact folders. If they differ in solc version or optimizer settings, the tested bytecode and the deployed bytecode are not the same, and contract verification on the block explorer can fail.
When both are kept, the decision is written down: which tool compiles the artifacts that get deployed, with which solc version and settings, and which continuous integration check confirms that both produce the same bytecode for production contracts. Without that check, a green test in one tool says nothing about what the other one deploys.
Hardhat vs Foundry in 2026: deployment decides, not the test language
Both tools handle compilation and test execution, fuzzing and invariant tests included, and since Hardhat 3 they do it on the same test format. For a new repository, Hardhat 3 fits when integration tests, deployment and contract consumption already live in TypeScript; Foundry fits when the project is mostly Solidity and is operated from the terminal. Neither turns a badly designed campaign into a reliable test or replaces a smart contract audit: the handler case shows that the result depends on which calls actually execute.
Published speed figures for either tool come from specific projects, versions and machines. If suite duration matters to the team, the useful measurement is its own: the same repository, the same solc version and the same number of cases, separating cold compilation, cached compilation and campaign duration.
We develop and audit smart contracts on EVM networks, and our audit includes reviewing what invariant tests actually cover. If you are choosing a tool for a project, tell us how it is deployed and who will operate it, and we will tell you which test and deployment setup fits it.
Frequently asked questions
Got a blockchain project in mind?
From idea to product, strategy and technology must move forward together.







