hardhat-v3-fork-testing

Run Foundry-style Solidity tests against a forked mainnet with Hardhat v3.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/phpmac/skills --skill hardhat-v3-fork-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hardhat-v3-fork-testing
Source: https://github.com/phpmac/skills/tree/main/plugins/my-agents/skills/hardhat-v3-fork-testing
Command: npx skills add https://github.com/phpmac/skills --skill hardhat-v3-fork-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Tests for interactions with deployed contracts on a forked mainnet using Hardhat v3 + Foundry-style Solidity tests, providing a safe, repeatable workflow.

Core Features & Use Cases

  • Provides a standardized approach for forked-mainnet testing with Hardhat v3.
  • Guides setup, test naming, and debugging for stateful scenarios and upgrade compatibility.
  • Suitable for validating real-chain state against deployed contracts in a controlled environment.

Quick Start

Follow this guide to author a forked-mainnet test and run it with your Hardhat test command.

Frequently Asked Questions about hardhat-v3-fork-testing

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

FAQPage Schema
How do I test smart contract interactions with deployed contracts on a forked mainnet?

Forked-mainnet testing validates smart contract interactions against real-chain state by using a fork RPC endpoint to simulate deployed contracts in a safe, repeatable environment. Hardhat v3 combined with Foundry-style Solidity tests provides this standardized workflow.

Can I use Foundry-style Solidity tests with Hardhat v3 for fork testing?

Yes, Foundry-style Solidity tests work with Hardhat v3 for forked-mainnet testing by adhering to the Foundry-style test structure. This approach guides setup, test naming, and debugging for stateful scenarios and upgrade compatibility validation.

What do I need to set up forked-mainnet testing in Hardhat v3?

Forked-mainnet testing in Hardhat v3 requires a fork RPC endpoint, the Hardhat v3 framework, and adherence to the Foundry-style test structure. You must configure your Hardhat test command to execute the forked tests against the provided RPC endpoint.

When should I use forked-mainnet testing for my Solidity smart contracts?

Forked-mainnet testing is needed when you must validate real-chain state, test interactions with deployed contracts, or verify upgrade compatibility. It provides a controlled environment to safely debug stateful scenarios before executing changes on the live network.

What is the best way to validate upgrade compatibility against deployed contracts?

The best way to validate upgrade compatibility is using forked-mainnet testing with Hardhat v3. It applies a standardized approach to safely test stateful scenarios and upgrade compatibility against real-chain state in a controlled, repeatable environment.

Why does my forked mainnet test fail to reproduce real-chain state in Hardhat?

Forked mainnet test failures often stem from an unstable fork RPC endpoint or deviation from the Foundry-style test structure. Ensure your Hardhat v3 environment is correctly configured and adheres to the required testing guidelines for repeatable results.