Guide · Agent skill
How to use the Web3 Smart Contract Testing agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
The web3-testing skill gives your AI agent a library of testing patterns for Solidity smart contracts, which are small programs that run on blockchains such as Ethereum and often hold real money. Once it is installed, the agent can draft unit tests, set up Hardhat or Foundry configuration, add fuzz tests, run tests against a copy of Ethereum mainnet, and add gas and coverage reporting. This guide is for developers who write or review Solidity and want faster test scaffolding; you will learn how to install the skill, trigger it, and review what it produces.
Quick start
- 1Download the ZIP. Get the web3-testing ZIP from the skill page on this site.
- 2Unzip into a skills folder. Place the folder in ~/.claude/skills/ for all projects, or in your project's .claude/skills/ folder for one project.
- 3Or upload it in the Claude apps. Go to Settings → Capabilities → Skills and upload the ZIP.
- 4Install your test tools. Install Node.js and Hardhat with its listed packages, or Foundry with forge-std, depending on the path you use.
- 5Make a natural request. Describe the contract and the tests you want, naming Hardhat or Foundry.
- 6Set environment variables. Store any RPC URL, API key or testnet private key in environment variables rather than in config files.
- 7Review and run the tests. Read every generated test, then run it with your framework and check the results.
What the web3-testing skill makes the agent do
An agent skill is a folder with a SKILL.md file that tells the agent when and how to handle a certain kind of task. The web3-testing skill covers smart contract testing with two frameworks: Hardhat, which is JavaScript-based, and Foundry, which uses Solidity for its tests.
The skill's guide covers unit tests, integration test suites, fixtures, revert and event checks, fuzzing with random inputs, Foundry cheatcodes, snapshot and revert between tests, mainnet forking, impersonating accounts, gas reporting, coverage reporting and Etherscan verification.
- Write unit tests for Solidity contracts
- Set up a Hardhat config with optimizer, gas reporter, coverage and Etherscan settings
- Write Foundry tests using forge-std, including fuzz tests
- Fork Ethereum mainnet to test against contracts such as DAI or Uniswap
- Compare gas usage between two implementations
Install the web3-testing skill
Download the web3-testing ZIP from the skill page on this site. The ZIP contains SKILL.md and references/details.md.
Option A (personal, all projects): unzip the folder into ~/.claude/skills/ so the skill is available everywhere on your machine.
Option B (one project only): unzip it into the .claude/skills/ folder inside your project.
Option C (Claude apps): upload the ZIP in the Claude apps under Settings → Capabilities → Skills.
Install the tools the skill needs
The skill does not install anything itself. Your project needs the tools its examples use. For the JavaScript path you need Node.js plus Hardhat with hardhat-toolbox, hardhat-gas-reporter, solidity-coverage and @nomiclabs/hardhat-etherscan. For the Solidity path you need Foundry (forge) with forge-std.
Optional services are an Ethereum mainnet RPC URL (for example from Alchemy), a CoinMarketCap API key for gas prices in USD, and an Etherscan API key for contract verification. A testnet private key is only needed if you deploy to Goerli.
- Node.js and Hardhat with the listed packages (JavaScript path)
- Foundry (forge) with forge-std (Solidity path)
- Optional: mainnet RPC URL, CoinMarketCap API key, Etherscan API key
- Optional: testnet private key for Goerli deployment, stored as an environment variable
Trigger the skill with a natural request
You do not need a special command. Describe the task in plain language and mention the contract or framework. The skill's description tells the agent to use it when you are testing Solidity contracts, setting up blockchain test suites, or validating DeFi protocols.
Be specific about what you want tested. The more concrete the request, the more useful the output.
- "Write Hardhat unit tests for my Token contract covering transfers, reverts and the Transfer event."
- "Set up Foundry fuzz tests for the transfer function in src/Token.sol."
- "Add a Hardhat config that reads the RPC URL and gas reporter key from environment variables."
- "Write a test that forks mainnet and swaps DAI on Uniswap."
- "Add gas and coverage reporting to our existing test suite."
Example: a Foundry test with a fuzz test
The Foundry examples in the skill inherit from forge-std's Test contract, set up contracts in setUp(), and use assertEq and vm.expectRevert. A fuzz test is a function that takes an argument, such as amount, which the tool fills with many random values. The example uses vm.assume to skip values outside the valid range.
Ask the agent to write tests in this style for your own contract, then run them with forge and review each assertion.
function testFuzzTransfer(uint256 amount) public {
vm.assume(amount > 0 && amount <= token.totalSupply());
vm.prank(owner);
token.transfer(user1, amount);
assertEq(token.balanceOf(user1), amount);
}Example: mainnet forking and impersonation
Forking runs your tests against a copy of live Ethereum mainnet at a fixed block, so you can call real contracts such as DAI. The skill's Hardhat example reads the RPC URL from the MAINNET_RPC_URL environment variable and pins blockNumber so results stay repeatable.
To act as an account that holds tokens, the skill uses hardhat_impersonateAccount. Only do this in test code against a fork.
await network.provider.request({
method: "hardhat_impersonateAccount",
params: [whaleAddress],
});Safety notes: keys, network and scripts
The skill does not run scripts, but it does use the network: forks and verification call remote RPC and Etherscan services. Keep all keys out of files you might share. The examples read PRIVATE_KEY, MAINNET_RPC_URL, ETHERSCAN_API_KEY and COINMARKETCAP_API_KEY from environment variables, and those variables must be protected.
Never use a private key that holds real funds in tests. Generated tests are a starting point, not a security audit.
- Store keys in environment variables, not in hardhat.config.js or committed files
- Use a separate testnet wallet for any deployment
- Review every generated test; wrong tests can give false confidence
- Do not treat passing tests as a professional security review
Tips for better results
Give the agent the contract source and the framework you use, so it writes tests that match your project. If you are new to Hardhat or Foundry, ask the agent to explain each config setting as it adds it. Ask for coverage with npx hardhat coverage when you want to see which lines the tests reach.
The skill's reference file holds more templates, including gas comparison tests between two implementations.
- Name the framework (Hardhat or Foundry) in your request
- Ask the agent to explain any unfamiliar config option
- Run the tests yourself and read failures before changing assertions
npx hardhat coverageWhat people use it for
- Scaffold a Hardhat test suite with fixtures for an ERC-20 token
- Write Foundry fuzz tests for a function that moves balances
- Test an integration against DAI or Uniswap by forking mainnet
- Compare gas use between two versions of a contract
- Add coverage reporting to an existing Solidity project
Frequently asked questions
Is the web3-testing skill free?
The skill is published under the MIT licence, as listed on this page. The tools it uses, such as Hardhat and Foundry, are separate projects with their own licences, and some services like Alchemy, CoinMarketCap and Etherscan need their own API keys.
What do I need before using it?
You need a Solidity project and either Node.js with Hardhat and its listed packages, or Foundry (forge) with forge-std. A mainnet RPC URL, CoinMarketCap key and Etherscan key are optional and only needed for forking, USD gas pricing and verification.
How do I install an agent skill?
Download the ZIP from this page and unzip it into ~/.claude/skills/ for all projects, or into a project's .claude/skills/ folder. You can also upload the ZIP in the Claude apps under Settings → Capabilities → Skills.
Does the skill run scripts on my computer?
No, according to the listing it does not run scripts. It does use the network, for example when a test forks mainnet through an RPC URL or when verifying contracts on Etherscan.
Can I use this skill without knowing Solidity?
It is not designed for that. The output is code that needs review by someone who understands Solidity, because wrong tests can give false confidence.
How does it compare with writing tests by hand or using a security audit?
The skill speeds up writing and scaffolding tests in Hardhat or Foundry. It does not replace a professional security review, and you should still read and check every generated test yourself.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Choose this skill if you write or maintain Solidity contracts and want a test suite or Hardhat and Foundry configuration scaffolded quickly, including fuzz and mainnet fork tests. Skip it if you have no Solidity experience, need a formal security audit, or would put real private keys directly into config files.
Download the skill