Configs2026年5月14日·1 分钟阅读

Foundry — Blazing Fast Ethereum Development Toolkit in Rust

Foundry is a portable, modular toolkit for Ethereum smart contract development written in Rust. It includes Forge for testing, Cast for chain interaction, Anvil for local node simulation, and Chisel for an interactive Solidity REPL. Foundry compiles and runs tests significantly faster than JavaScript-based alternatives.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Foundry
通用 CLI 安装命令
npx tokrepo install 2b86396f-4f90-11f1-9bc6-00163e2b0d79

Introduction

Foundry is an Ethereum development toolkit built in Rust by Paradigm. It replaces JavaScript-based workflows with native-speed tooling for compiling, testing, deploying, and interacting with smart contracts. Foundry has become the preferred toolkit for teams that write tests in Solidity rather than JavaScript.

What Foundry Does

  • Compiles Solidity and Vyper contracts with parallel compilation via forge build
  • Runs Solidity-native unit and fuzz tests at native speed with forge test
  • Provides cast CLI for sending transactions, querying chain state, and decoding calldata
  • Spins up a local Ethereum node with anvil for development and forked mainnet testing
  • Offers chisel, an interactive Solidity REPL for quick experimentation

Architecture Overview

Foundry is a set of Rust binaries sharing a common library layer. Forge handles project management, compilation (via solc), and test execution using a built-in EVM (revm). Anvil implements a full JSON-RPC server backed by revm, supporting mainnet forking at any block. Cast wraps common RPC calls and ABI encoding into one-line CLI commands. The toolkit uses the Alloy library for Ethereum type handling and RPC transport.

Self-Hosting & Configuration

  • Install via foundryup or build from source with cargo build --release
  • Configure project settings in foundry.toml (Solidity version, optimizer runs, RPC URLs)
  • Use forge install to manage Solidity dependencies as Git submodules
  • Set ETH_RPC_URL environment variable for default chain interaction
  • Fork mainnet with anvil --fork-url <RPC_URL> for realistic integration tests

Key Features

  • Fuzz testing with configurable runs and shrinking for finding edge cases
  • Mainnet forking in Anvil lets you test against live contract state
  • Gas snapshots (forge snapshot) track contract gas usage across commits
  • Cheatcodes in tests allow time manipulation, storage overrides, and impersonation
  • Script system (forge script) deploys contracts with simulation before broadcast

Comparison with Similar Tools

  • Hardhat — JavaScript-based with a rich plugin ecosystem; Foundry is faster and uses Solidity for tests
  • Brownie — Python-based framework now largely unmaintained; Foundry is actively developed
  • Truffle — Early Ethereum framework; Foundry offers modern DX and superior test speed
  • Ape — Python framework by ApeWorX; Foundry appeals to developers preferring Solidity-native testing

FAQ

Q: Can I use Foundry alongside Hardhat? A: Yes. Many teams use Forge for testing and Hardhat for deployment scripts or plugins. The two can coexist in the same repository.

Q: Does Foundry support Vyper? A: Foundry supports compiling Vyper contracts, though the primary testing workflow targets Solidity.

Q: How does fuzz testing work in Forge? A: Forge generates random inputs for test function parameters and runs them many times (default 256 runs). Failing inputs are automatically minimized to the simplest reproducing case.

Q: Is Foundry production-ready? A: Yes. Major protocols including Uniswap, Optimism, and Paradigm use Foundry in production.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产