smart-contract-testing

smart-contract-testing is a skill for Claude Code, Codex from nirholas/three.ws. It costs 33 tokens per session (1,385 once invoked), scanned A, original, Apache-2.0.

A guide to testing Solidity smart contracts with Foundry or Hardhat. It covers checks that verify contract behavior, including random-input and blockchain-state tests.

In plain words
What is it for?
Writing unit, fuzz, invariant, and fork tests; debugging failed contract tests; and benchmarking gas usage.
Why use it?
It helps find contract bugs and confirm that changes do not break expected behavior. It also explains how to investigate failed tests and check gas use.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/nirholas/three.ws/smart-contract-testing
Any agent
npx skills add nirholas/three.ws --skill smart-contract-testing
Clone the repo
git clone --depth 1 https://github.com/nirholas/three.ws

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for smart-contract-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/nirholas/three.ws/smart-contract-testing.svg)](https://agentmods.dev/skills/nirholas/three.ws/smart-contract-testing)
Your own site
<a href="https://agentmods.dev/skills/nirholas/three.ws/smart-contract-testing"><img src="https://agentmods.dev/badge/skills/nirholas/three.ws/smart-contract-testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 33 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,385 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00033 $0.01385
Opus 5 $0.00016 $0.00692
Sonnet 5 $0.00007 $0.00277
Haiku 4.5 $0.00003 $0.00138

Measured 2d ago against content hash f2686ee6864a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

smart-contract-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

data/skills/development/smart-contract-testing/SKILL.md · 204 lines

How it starts

The opening of the file, as written. The whole thing — 204 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Smart Contract Testing

When to use this skill

Use when the user asks about:

  • Writing tests for smart contracts
  • Setting up a testing framework (Foundry or Hardhat)
  • Fuzz testing or invariant testing strategies
  • Fork testing against mainnet state
  • Gas benchmarking and optimization verification
  • Debugging failing contract tests

Testing Framework Selection

Foundry vs Hardhat

Feature Foundry Hardhat
Language Solidity JavaScript/TypeScript
Speed Very fast (native) Slower (JS runtime)
Fuzzing Built-in Requires plugins
Fork testing Built-in Built-in
Debugging forge debug, traces console.sol, traces
Ecosystem Growing rapidly Mature, large plugin ecosystem

Recommendation: Use Foundry for new projects. Use Hardhat when you need complex JS scripting or specific Hardhat plugins.

Testing with Foundry

1. Unit Test Structure

Follow this pattern for each test:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {Test} from "forge-std/Test.sol";
import {MyContract} from "../src/MyContract.sol";

contract MyContractTest is Test {
    MyContract internal target;
    address internal alice = makeAddr("alice");
    address internal bob = makeAddr("bob");

    function setUp() public {
        target = new MyContract();
        deal(alice, 100 ether);
    }

    function test_deposit_succeeds() public {
        vm.prank(alice);
        target.deposit{value: 1 ether}();
        assertEq(target.balanceOf(alice), 1 ether);
    }

    function test_deposit_revertsWhenZero() public {
        vm.prank(alice);
        vm.expectRevert(MyContract.ZeroAmount.selector);
        target.deposit{value: 0}();
    }
}

Naming conventions:

  • test_functionName_scenario for expected-pass tests
  • test_functionName_revertsWhen_condition for expected-revert tests
  • testFuzz_functionName for fuzz tests

2. Fuzz Testing

Let Foundry generate random inputs to find edge cases:

Read the full file on GitHub · 204 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 204 lines · 33 tokens per session scan A f2686ee6864a

Subscribe to this mod's changes

smart-contract-testing is a skill published in the GitHub repository nirholas/three.ws (110 stars, last pushed today), licensed Apache-2.0. It adds 33 tokens to every session and 1,385 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

blockchain-testing

Use this skill when asked about testing smart contracts, Foundry tests, Hardhat tests, fuzz testing, invariant testing, property-based testing, formal verification, audit preparation, integration testing for dApps, and blockchain testing patterns. Covers Foundry cheatcodes, Echidna fuzzing, Certora verification…

j4flmao/agent-skills · 117 tokens

generate-tests

Creates comprehensive test suites for Move contracts with 100% coverage requirement. Triggers on: 'generate tests', 'create tests', 'write test suite', 'test this contract', 'how to test', 'add test coverage', 'write unit tests'.

aptos-labs/aptos-agent-skills · 54 tokens

Smart Contract Testing

Smart contract testing with Hardhat, Foundry, and Brownie including unit tests, gas optimization, reentrancy checks, and fork testing.

PramodDutta/qaskills · 33 tokens

cadence-testing

Guide for writing, running, and debugging unit tests for Cadence smart contracts using the built-in Cadence Testing Framework and flow test. Covers test file structure (test.cdc, setup/beforeEach/tearDown), assertions and matchers, blockchain emulation (accounts, deployments, events, time manipulation), coverage…

onflow/flow-ai-tools · 264 tokens

blockchain-cross-chain

Cross-chain protocols, IBC, LayerZero, Wormhole, Axelar, CCIP, bridges, atomic composability, shared sequencer, cross-chain message passing. Covers trust models (light clients, external validators, ZK proofs), bridge security, token representation (canonical, wrapped, native), relayer economics, and cross-chain…

j4flmao/agent-skills · 108 tokens

blockchain-security

Use this skill when asked about blockchain security, smart contract auditing, DeFi threat modeling, blockchain incident response, bug bounty programs, economic security, formal verification of smart contracts, and blockchain-specific security analysis. Languages: Solidity, Python, Rust, Haskell. Covers threat modeling…

j4flmao/agent-skills · 203 tokens