foundry

Build, test, deploy, and debug Solidity smart contracts with the Foundry toolkit.

6|20|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/andresdefi/cryptoskills --skill foundry-andresdefi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: foundry
Source: https://github.com/andresdefi/cryptoskills/tree/main/skills/foundry
Command: npx skills add https://github.com/andresdefi/cryptoskills --skill foundry-andresdefi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI agents often have stale knowledge of Foundry workflows, producing outdated deployment patterns, incorrect cast usage, and broken test syntax. This Skill provides current, correct guidance for the full Solidity development lifecycle — compilation, unit/fuzz/invariant/fork testing, scripted deployment, verification, and debugging — on any EVM chain. ## Core Features & Use Cases - Testing Patterns: Unit, fuzz, invariant, and fork testing with forge-std cheatcodes (vm.prank, vm.deal, vm.expectRevert, snapshots, mocking) and ready-to-use example suites. - Deployment & Verification: forge script workflows with broadcast artifacts, CREATE2 deterministic addresses, hardware wallet support, resume-after-failure, and Etherscan verification. - Chain Interaction & Debugging: cast commands for reading state, sending transactions, ABI encoding/decoding, plus troubleshooting guides for stack-too-deep, gas, nonce, and RPC issues. - Use Case: Ask the agent to write a fork test that impersonates a USDC whale on mainnet, or to deploy a multi-contract protocol to Sepolia with verification — it will produce correct, current Foundry code. ## Quick Start Ask the agent to set up a new Foundry project with a fuzz test for a vault contract and a deployment script for Sepolia.

Frequently Asked Questions about foundry

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

FAQPage Schema
How do I write a fuzz test in Foundry?

Add parameters to any test function and Foundry auto-generates random inputs. Use bound() to clamp values into a valid range rather than vm.assume, which discards runs. Configure iteration counts in the [fuzz] section of foundry.toml.

How do I deploy a contract with forge script?

Write a Solidity script extending forge-std Script with vm.startBroadcast around deployment calls, then run forge script with --rpc-url and --broadcast. Always dry-run without --broadcast first, and use --slow plus --verify on mainnet.

What is the difference between cast call and cast send?

cast call simulates a function and returns its value without sending a transaction or costing gas. cast send submits a state-changing transaction and returns a receipt, not the function's return value.

How do I fix the stack too deep error in Solidity?

Enable the IR compilation pipeline by setting via_ir = true in foundry.toml under [profile.default]. If the error persists, refactor the function to use fewer local variables or split logic into internal helpers.

Does Foundry support testing against mainnet state?

Yes, fork testing uses vm.createSelectFork with an RPC endpoint to run tests against live chain state. Pin a block number for deterministic results and to enable Foundry's local RPC cache.

Why does vm.prank only work for one call?

vm.prank applies only to the next call by design. Use vm.startPrank to impersonate an address across multiple calls, then vm.stopPrank to end the impersonation.