hardhat

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

2|Updated Jun 20, 2026
One-click install
npx skills add https://github.com/solomongetnet/eip-712-gasless --skill hardhat-solomongetnet
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: hardhat
Source: https://github.com/solomongetnet/eip-712-gasless/tree/main/contracts/.agents/skills/hardhat
Command: npx skills add https://github.com/solomongetnet/eip-712-gasless --skill hardhat-solomongetnet

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Hardhat 3 introduces a new test architecture with two distinct test layers, a new network connection API, and ESM-only constraints. This Skill helps you choose the right test layer, use forge-std cheatcodes correctly, and avoid common mistakes with network.create(), networkHelpers, and the compile-then-typecheck workflow. ## Core Features & Use Cases - Test layer selection: Decide between Solidity tests (.t.sol, in-EVM, cheatcode access) and TypeScript tests (off-chain orchestration, multi-contract flows) based on what you are testing. - Cheatcode and networkHelpers reference: Covers vm.prank, vm.deal, vm.warp, vm.expectRevert, plus typed helpers like time.increase, mine, impersonateAccount, loadFixture, and snapshots. - Compile-then-typecheck workflow: Ensures generated contract types stay in sync by running npx hardhat build && npx tsc --noEmit before tests. - Use Case: You are adding tests to a Hardhat 3 project using the viem toolbox. The Skill tells you to write Solidity unit tests with forge-std assertions, use network.create() for an isolated TypeScript integration test, and pair it with the hardhat-toolbox-viem skill for client-specific calls. ## Quick Start Ask the AI to write Hardhat 3 tests for your contract, choosing Solidity or TypeScript tests appropriately and using networkHelpers for fixtures and time manipulation.

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 Solidity tests (`.t.sol` files or any `.sol` file in `test/`) for unit tests and TypeScript tests in `test/` for off-chain orchestration. Run all tests with `hardhat test`, or scope to a layer with `hardhat test solidity`, `hardhat test nodejs`, or `hardhat test mocha`.

Should I use Solidity or TypeScript tests in Hardhat?▼

Use Solidity tests by default for unit tests on individual contracts since they run in the EVM with cheatcode access. Use TypeScript tests only when you need off-chain orchestration like multi-contract interactions, fixture reuse, or gas and balance assertions from the outside.

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

Import `Test` from forge-std in your Solidity test contract to access the `vm` object. Common cheatcodes include `vm.prank(addr)` for the next call's sender, `vm.deal` for balances, `vm.warp` for timestamps, and `vm.expectRevert` for revert assertions.

What is network.create() in Hardhat 3 TypeScript tests?▼

`network.create()` from the `hardhat` import creates a network connection with an isolated blockchain state, extended by toolbox plugins with `viem` or `ethers` plus `networkHelpers`. Create one connection per file, suite, or test depending on how much state isolation you need.

Why do my Hardhat TypeScript tests have type errors after changing a contract?▼

Generated contract types derive from the compiled ABI, so editing a contract without recompiling leaves stale types. Run `npx hardhat build && npx tsc --noEmit` to recompile first and then typecheck before running the test suite.

Does Hardhat 3 support CommonJS or top-level await?▼

Hardhat 3 only works with ESM, so top-level `await` is available in TypeScript test files. This means you can call `await network.create()` directly at module scope when a single shared connection suits the whole file.