hardhat

Guides writing and running Solidity and TypeScript tests in Hardhat 3 projects.

Updated Jul 18, 2026
One-click install
npx skills add https://github.com/TuxPenguin09/paychain --skill hardhat-tuxpenguin09
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: hardhat
Source: https://github.com/TuxPenguin09/paychain/tree/main/contracts/.agents/skills/hardhat
Command: npx skills add https://github.com/TuxPenguin09/paychain --skill hardhat-tuxpenguin09

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Hardhat 3 introduces a dual test-layer model (Solidity tests and TypeScript tests), a new network connection API, and ESM-only constraints that differ sharply from Hardhat 2. This Skill helps developers choose the right test layer, use forge-std cheatcodes and networkHelpers correctly, and avoid common mistakes like typechecking before compiling. ## Core Features & Use Cases - Test Layer Selection: Decide between Solidity tests (.t.sol, in-EVM, fuzz support) and TypeScript tests (off-chain orchestration, multi-contract flows) based on what the test actually needs. - Cheatcodes & State Manipulation: Use forge-std vm cheatcodes (prank, deal, warp, expectRevert) in Solidity tests and networkHelpers (time, mine, impersonateAccount, loadFixture, snapshots) in TypeScript tests. - Compile-Then-Typecheck Workflow: Run hardhat build before tsc --noEmit so generated contract types catch argument and payable errors early. - Use Case: When adding a test for a PayChain salary disbursement contract, use this Skill to write a Solidity fuzz test for the core logic and a TypeScript test with loadFixture for the end-to-end employer-to-worker payment flow. ## Quick Start Ask the AI to write a Hardhat 3 test for your smart contract, choosing between a Solidity test with forge-std cheatcodes or a TypeScript test using network.create() and networkHelpers.

Frequently Asked Questions about hardhat

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write tests in Hardhat 3?▼

Hardhat 3 supports two test layers: Solidity tests (.t.sol files) for unit tests running directly in the EVM, and TypeScript tests (test/*.ts) for off-chain orchestration. Run all tests with hardhat test, or scope to one layer with hardhat test solidity, nodejs, or mocha.

Should I use Solidity tests or TypeScript tests in Hardhat?▼

Use Solidity tests for unit tests on individual contracts since they compile-check against the real ABI and support cheatcodes and fuzzing. Use TypeScript tests only when you need multi-contract orchestration, shared fixtures, or external assertions about gas and balances.

How do I use cheatcodes like vm.prank in Hardhat 3?▼

Import Test from forge-std/Test.sol in your Solidity test contract to access the vm object. Common cheatcodes include vm.prank for msg.sender, vm.deal for balances, vm.warp for timestamps, and vm.expectRevert for revert assertions.

What is networkHelpers in Hardhat 3 TypeScript tests?▼

networkHelpers is a typed API exposed by network.create() for EVM state manipulation, covering time control, block mining, account impersonation, balance setting, loadFixture for cached deployments, and manual snapshots. It replaces raw JSON-RPC helper calls.

Why do my Hardhat 3 TypeScript tests have type errors?▼

Generated contract types come from the compiled ABI, so you must compile before typechecking. Run npx hardhat build && npx tsc --noEmit so the compiler catches wrong argument types and invalid options like value on non-payable functions.

Does Hardhat 3 support fuzz testing?▼

Yes, Solidity test functions with parameters (like testFuzz_Inc(uint8 x)) are automatically run with many random inputs. This works in any contract inheriting forge-std Test that contains at least one function whose name starts with test.