web3-testing

Automate Solidity smart contract testing with Hardhat and Foundry.

4|Updated Mar 3, 2026
One-click install
npx skills add https://github.com/AI-Foundry-Core/ril-agents --skill web3-testing-ai-foundry-core
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: web3-testing
Source: https://github.com/AI-Foundry-Core/ril-agents/tree/main/plugins/blockchain-web3/skills/web3-testing
Command: npx skills add https://github.com/AI-Foundry-Core/ril-agents --skill web3-testing-ai-foundry-core

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

Test smart contracts comprehensively using Hardhat and Foundry with unit tests, integration tests, and mainnet forking. Use when testing Solidity contracts, setting up blockchain test suites, or validating DeFi protocols.

Core Features & Use Cases

  • Hardhat Testing Setup: Configure and run tests with Hardhat, including forking and coverage.
  • Unit & Foundry Testing Patterns: Write and execute unit tests (JavaScript/TypeScript) and Forge tests (Solidity), including fuzzing and time-based tests.
  • Mainnet Forking & Advanced Scenarios: Execute tests against forked mainnet contracts, impersonate accounts, and simulate real-world conditions.
  • Gas & Coverage Analysis: Measure gas usage, ensure coverage, and verify contracts.
  • CI/CD & Verification: Integrate tests into CI, generate coverage reports, and verify on Etherscan.

Quick Start

Install Hardhat and Foundry, then run the provided tests to validate your Solidity contracts.

Frequently Asked Questions about web3-testing

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

FAQPage Schema
How do I set up mainnet forking to test Solidity smart contracts?

Mainnet forking for Solidity smart contracts requires a project configuration that enables forking alongside Hardhat and Foundry. This setup validates DeFi protocols by simulating real-world conditions against forked mainnet contracts and impersonating accounts.

What is the best way to write unit tests for smart contracts using Foundry and Hardhat?

The best way to write unit tests for smart contracts is combining Hardhat JavaScript or TypeScript tests with Foundry Forge Solidity tests. This approach covers standard execution paths alongside fuzzing and time-based tests.

Do I need both Hardhat and Foundry to run integration tests on DeFi protocols?

Yes, comprehensive integration tests for DeFi protocols require both Hardhat and Foundry. The combined toolchain supports mainnet fork scenarios, gas reporting, and contract verification to fully validate contract behavior.

How do I measure gas usage and generate coverage reports for Solidity contracts?

Measure gas usage and generate coverage reports for Solidity contracts by configuring Hardhat and Foundry project settings. This provides gas reporting and coverage analysis to ensure efficient and fully tested contract behavior.

Can I integrate smart contract tests into CI and verify them on Etherscan?

Yes, you can integrate smart contract tests into CI pipelines to automate execution and generate coverage reports. The workflow supports contract verification on Etherscan directly through the configured Hardhat and Foundry environment.