Skills web3-testing
📦

web3-testing

Safe 🔑 Env variables

Test smart contracts with Hardhat

Writing comprehensive tests for smart contracts is complex and time-consuming. This skill provides ready-to-use patterns for unit tests, integration tests, fuzzing, gas optimization, and mainnet forking using Hardhat and Foundry.

Supports: Claude Codex Code(CC)
📊 71 Adequate
1

Download the skill ZIP

2

Upload in Claude

Go to Settings → Capabilities → Skills → Upload skill

3

Toggle on and start using

Test it

Using "web3-testing". Write a Hardhat unit test for an ERC20 token contract

Expected outcome:

  • Deployment test: Verifies owner assignment and total supply
  • Transfer test: Confirms token transfers between accounts
  • Event test: Checks Transfer and Approval event emissions
  • Balance test: Validates balance changes after transfers
  • Time test: Tests time-locked token release functionality

Using "web3-testing". Create a Foundry test for token transfers with fuzzing

Expected outcome:

  • Fuzz test: Tests transfers with random amounts within valid range
  • Boundary test: Handles zero and maximum transfer amounts
  • Prank test: Simulates different sender addresses
  • Event test: Verifies emitted Transfer events with correct parameters

Security Audit

Safe
v4 • 1/17/2026

Documentation-only skill containing code examples and best practices for smart contract testing. Static findings are false positives triggered by blockchain testing terminology (prank, fork, deal), environment variable references demonstrating secure secret handling patterns, and markdown code block syntax. The skill teaches recommended security practices and has no executable code, network calls, or file access capabilities.

2
Files scanned
595
Lines analyzed
1
findings
4
Total audits

Risk Factors

🔑 Env variables (1)
Audited by: claude View Audit History →

Quality Score

38
Architecture
100
Maintainability
85
Content
30
Community
100
Security
91
Spec Compliance

What You Can Build

Set up test suites

Create comprehensive test suites for Solidity contracts using Hardhat and Foundry patterns.

Validate DeFi integrations

Test smart contracts against mainnet forks of existing DeFi protocols like Uniswap.

Fuzz contract logic

Use Foundry fuzzing to discover edge cases and potential vulnerabilities in smart contracts.

Try These Prompts

Basic Unit Test
Write a Hardhat unit test for an ERC20 token contract that tests deployment, transfers, and approval events.
Integration Test
Create an integration test for a staking contract that tests deposit, claim rewards, and withdrawal flows using Hardhat.
Mainnet Fork
Write a test that forks Ethereum mainnet and tests Uniswap V2 swap functionality with a fork of the DAI token.
Gas Optimization
Create a gas comparison test between two different implementations of the same smart contract function using Hardhat gas reporter.

Best Practices

  • Use fixtures to avoid code duplication across multiple test cases
  • Aim for at least 90% test coverage on critical contract functions
  • Test edge cases like zero addresses, maximum values, and reentrancy scenarios

Avoid

  • Avoid testing multiple unrelated scenarios in a single test function
  • Do not use mainnet forking in all tests - reserve for integration scenarios
  • Avoid hardcoding private keys or secrets in test files

Frequently Asked Questions

What testing frameworks are supported?
Hardhat with Chai/Ethers.js and Foundry with Forge are both supported with complete examples.
What is the maximum test coverage recommended?
Aim for 90% or higher coverage on critical contracts. Use npx hardhat coverage to generate reports.
Can this skill interact with mainnet directly?
No. The skill provides patterns for mainnet forking but users configure their own RPC endpoints and keys.
Is my private key data safe?
Yes. The skill only provides example patterns. Users add their own keys to environment variables in their projects.
Why are my tests failing with timeout errors?
Increase Hardhat timeout in hardhat.config.js or break large tests into smaller functions with fewer assertions.
How is Foundry different from Hardhat?
Foundry uses Solidity for tests and runs faster with built-in fuzzing. Hardhat uses JavaScript with more flexibility for complex integrations.

Developer Details

File structure

📄 SKILL.md