I've used both Hardhat and Foundry in production projects. Smart contracts on Ethereum, Polygon, and BSC. Here's an honest comparison based on real experience, not documentation screenshots.
Hardhat: The JavaScript-Native Approach
Hardhat is the incumbent. Mature ecosystem, extensive plugin library, huge community. If you've done any Solidity development, you've probably used Hardhat.
What I like:
- Plugin ecosystem (ethers.js integration, gas reporter, coverage, verify)
-
console.login Solidity during development — this alone saves hours - TypeScript support for tests and scripts
- Hardhat Network for local testing with mainnet forking What frustrates me:
- Tests in JavaScript/TypeScript are verbose for testing Solidity
- Compilation speed is noticeably slower than Foundry on large projects
- Configuration can get complex with many plugins My Hardhat test for the SBT project:
import { expect } from "chai";
import { ethers } from "hardhat";
describe("SoulboundCertificate", function () {
let sbt: any;
let owner: any;
let recipient: any;
beforeEach(async function () {
[owner, recipient] = await ethers.getSigners();
const SBT = await ethers.getContractFactory("SoulboundCertificate");
sbt = await SBT.deploy();
});
it("Should block transfers between addresses", async function () {
await sbt.mint(recipient.address, "ipfs://test-uri");
const [, , other] = await ethers.getSigners();
await expect(
sbt.connect(recipient).transferFrom(
recipient.address,
other.address,
0
)
).to.be.revertedWith("SBT: transfer not allowed");
});
});
Foundry: The Solidity-Native Approach
Foundry (by Paradigm) is the challenger. Tests written in Solidity, blazing fast compilation, built-in fuzzing. It's what the cool kids use. But is it actually better?
What I like:
- Tests in Solidity — you test Solidity WITH Solidity. No context switching.
- Speed. Compilation and tests are 5-10x faster than Hardhat on the same project.
- Built-in fuzzing with
forge fuzz— essential for security -
forge scriptfor deployments is cleaner than Hardhat scripts -
chiselREPL for quick experimentation What frustrates me: - Smaller plugin ecosystem
- Less documentation and fewer Stack Overflow answers
- Frontend integration requires more manual setup (no native ethers.js plugin)
- Steeper learning curve if you're coming from JavaScript Same test in Foundry:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "forge-std/Test.sol";
import "../src/SoulboundCertificate.sol";
contract SBTTest is Test {
SoulboundCertificate sbt;
address recipient = makeAddr("recipient");
address other = makeAddr("other");
function setUp() public {
sbt = new SoulboundCertificate();
}
function test_BlockTransfer() public {
sbt.mint(recipient, "ipfs://test-uri");
vm.prank(recipient);
vm.expectRevert("SBT: transfer not allowed");
sbt.transferFrom(recipient, other, 0);
}
// Fuzz test — Foundry runs this with random inputs
function testFuzz_MintToAnyAddress(address to) public {
vm.assume(to != address(0));
sbt.mint(to, "ipfs://test-uri");
assertEq(sbt.ownerOf(0), to);
}
}
Notice the fuzz test at the bottom. Foundry automatically runs it with hundreds of random addresses. This catches edge cases that manual tests miss. This is the kind of testing I apply in every smart contract audit.
My Recommendation
Use Foundry if:
- Your project is primarily smart contracts
- Security is critical (DeFi, high-value assets)
- You want the fastest development cycle
- Your team is comfortable with Solidity Use Hardhat if:
- You're building a full-stack DApp with significant frontend
- Your team is stronger in TypeScript than Solidity
- You need specific plugins (e.g., hardhat-deploy, gas-reporter)
- You're working with less experienced developers who need more resources What I actually do: I use both. Foundry for smart contract development and testing (faster, better fuzzing). Hardhat for deployment scripts and frontend integration (better ethers.js support). The two can coexist in the same project.
The Real Answer
The framework matters less than: writing comprehensive tests, running static analysis (Slither), doing fuzz testing, and having a proper audit before mainnet deployment.
A well-tested contract in Hardhat beats a poorly-tested contract in Foundry every time.
I'm Drilon, a blockchain and full-stack developer working with businesses on Ethereum, Polygon, BSC, and TON. More technical deep-dives on my blog.
Top comments (0)