--- title: "Foundry" type: entity tags: [tool, development-framework, testing] sources: [blockchain-security-auditor] last_updated: 2026-04-20 --- ## 定义 Foundry 是以太坊开发框架,包含 Forge(智能合约测试工具)和 Cast(交互工具),使用 Solidity 编写测试,支持高速测试执行和模糊测试。 ## 核心功能 - **Forge**:智能合约测试框架 - **Cast**:链上交互 CLI - **Anvil**:本地测试网络 - **Chisel**:Solidity REPL ## 在审计中的应用 ```solidity // Foundry Exploit PoC 示例 contract FlashLoanOracleExploitTest is Test { function test_oracleManipulationExploit() public { // 复现漏洞的 Foundry 测试 } } ``` ## 与传统测试对比 | 特性 | Forge | Hardhat | |------|-------|---------| | 语言 | Solidity | JavaScript/TypeScript | | 速度 | 快(Rust) | 较慢 | | Fuzzing | 内置 | 需集成 Echidna | ## Connections - [[Smart Contract Testing]] ← provides ← [[Foundry]] - [[Invariant Verification]] ← supports ← [[Foundry]]