foundry
Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
Top Related Projects
Dapp, Seth, Hevm, and more
:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
OpenZeppelin Contracts is a library for secure smart contract development.
Mythril is a symbolic-execution-based securty analysis tool for EVM bytecode. It detects security vulnerabilities in smart contracts built for Ethereum and other EVM-compatible blockchains.
Static Analyzer for Solidity and Vyper
Quick Overview
Foundry is a blazing fast, portable, and modular toolkit for Ethereum application development written in Rust. It provides a comprehensive suite of tools for smart contract development, testing, and deployment, offering a more efficient and developer-friendly alternative to traditional Ethereum development environments.
Pros
- Extremely fast compilation and testing speeds due to its Rust implementation
- Highly customizable and extensible with a modular architecture
- Native support for Solidity and Vyper languages
- Robust testing framework with built-in fuzzing capabilities
Cons
- Steeper learning curve for developers not familiar with Rust or command-line tools
- Less extensive documentation compared to more established tools like Truffle
- Smaller ecosystem and community support compared to older alternatives
- May require additional setup for integration with certain IDEs or development workflows
Code Examples
- Writing a simple test in Foundry:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "../src/Counter.sol";
contract CounterTest is Test {
Counter public counter;
function setUp() public {
counter = new Counter();
}
function testIncrement() public {
counter.increment();
assertEq(counter.number(), 1);
}
}
- Using Foundry's cheatcodes in tests:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
contract CheatcodeTest is Test {
function testPrank() public {
address alice = address(0x1);
vm.prank(alice);
// The next call will be made with alice's address
assertEq(msg.sender, alice);
}
}
- Fuzzing example in Foundry:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
contract FuzzTest is Test {
function testFuzz_AdditionIsCommutative(uint256 x, uint256 y) public {
// This test will run multiple times with different random inputs
assertEq(x + y, y + x);
}
}
Getting Started
To get started with Foundry:
-
Install Foundry:
curl -L https://foundry.paradigm.xyz | bash foundryup -
Create a new project:
forge init my_project cd my_project -
Compile the project:
forge build -
Run tests:
forge test
For more detailed instructions and advanced usage, refer to the official Foundry documentation.
Competitor Comparisons
Dapp, Seth, Hevm, and more
Pros of Dapptools
- Mature ecosystem with a comprehensive suite of tools (seth, dapp, hevm)
- Strong support for formal verification and property-based testing
- Extensive documentation and established community resources
Cons of Dapptools
- Steeper learning curve, especially for developers new to Ethereum
- Slower development cycle and less frequent updates
- Limited cross-platform support (primarily focused on Unix-like systems)
Code Comparison
Dapptools (using dapp):
dapp test
dapp build
dapp deploy
Foundry:
forge test
forge build
forge create
Key Differences
- Foundry is written in Rust, while Dapptools is primarily written in Nix and Haskell
- Foundry offers faster compilation and testing times compared to Dapptools
- Foundry provides better Windows support and easier installation process
- Dapptools has a more extensive set of integrated tools, while Foundry focuses on core development features
Both projects aim to improve Ethereum development workflows, but Foundry emphasizes speed and ease of use, while Dapptools offers a more comprehensive toolkit with advanced features for formal verification and property-based testing.
:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
Error generating comparison
Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
Pros of Hardhat
- Extensive JavaScript ecosystem integration
- Well-established with a large community and plugin ecosystem
- Flexible configuration options for diverse project needs
Cons of Hardhat
- Slower test execution compared to Foundry
- JavaScript-based, which may be less efficient for some operations
- Steeper learning curve for developers new to JavaScript/TypeScript
Code Comparison
Hardhat (JavaScript):
const { expect } = require("chai");
describe("Token", function() {
it("Should return the new token name", async function() {
const Token = await ethers.getContractFactory("Token");
const token = await Token.deploy();
expect(await token.name()).to.equal("MyToken");
});
});
Foundry (Solidity):
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "../src/Token.sol";
contract TokenTest is Test {
function testName() public {
Token token = new Token();
assertEq(token.name(), "MyToken");
}
}
The code comparison showcases the different approaches: Hardhat uses JavaScript with Chai assertions, while Foundry employs Solidity with built-in assertions. Foundry's tests are more concise and closer to the contract language, potentially offering a more intuitive experience for Solidity developers.
OpenZeppelin Contracts is a library for secure smart contract development.
Pros of OpenZeppelin Contracts
- Comprehensive library of secure, audited smart contract components
- Widely adopted and battle-tested in production environments
- Extensive documentation and community support
Cons of OpenZeppelin Contracts
- Limited to contract development, not a full development environment
- May require additional tools for testing and deployment
Code Comparison
OpenZeppelin Contracts:
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 1000000 * 10 ** decimals());
}
}
Foundry:
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
contract CounterTest is Test {
function setUp() public {}
function testIncrement() public {}
}
Key Differences
- OpenZeppelin Contracts focuses on providing reusable smart contract components
- Foundry is a complete Ethereum development environment with testing, deployment, and debugging tools
- OpenZeppelin Contracts is primarily used for contract development, while Foundry covers the entire development lifecycle
- Foundry includes a powerful testing framework, whereas OpenZeppelin Contracts requires external testing tools
Mythril is a symbolic-execution-based securty analysis tool for EVM bytecode. It detects security vulnerabilities in smart contracts built for Ethereum and other EVM-compatible blockchains.
Pros of Mythril
- Specialized in security analysis and vulnerability detection for smart contracts
- Supports multiple blockchain platforms beyond Ethereum
- Utilizes symbolic execution and SMT solving for in-depth analysis
Cons of Mythril
- Steeper learning curve for non-security experts
- May produce false positives that require manual verification
- Less integrated development environment compared to Foundry
Code Comparison
Mythril (vulnerability detection):
def check_integer_overflow(self, state, node):
state.world_state.constraints.append(
ULT(node.value, BitVecVal(2**256 - 1, 256))
)
return [Issue(...)]
Foundry (testing framework):
function testExample() public {
uint256 a = 1;
uint256 b = 2;
assertEq(a + b, 3);
}
While Mythril focuses on security analysis, Foundry provides a comprehensive testing and development environment for Ethereum smart contracts. Mythril excels in detecting vulnerabilities, but Foundry offers a more user-friendly experience for general smart contract development and testing.
Static Analyzer for Solidity and Vyper
Pros of Slither
- Specialized in static analysis and vulnerability detection
- Supports multiple smart contract languages (Solidity, Vyper)
- Extensive set of built-in detectors for common vulnerabilities
Cons of Slither
- Limited testing capabilities compared to Foundry
- Steeper learning curve for configuring and customizing detectors
- Less focus on development workflow integration
Code Comparison
Slither (running a security analysis):
slither contracts/
Foundry (running tests):
forge test
Slither focuses on static analysis and vulnerability detection, while Foundry is a comprehensive development toolkit. Slither excels in identifying potential security issues across multiple smart contract languages, but has limited testing capabilities. Foundry, on the other hand, offers a more integrated development experience with powerful testing features, but may not provide as extensive security analysis out of the box.
Slither's strength lies in its specialized detectors and ability to analyze contracts written in different languages. Foundry shines in its testing framework, fast compilation, and overall development workflow. While both tools are valuable for smart contract developers, they serve different primary purposes and can be complementary in a comprehensive development and security pipeline.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Blazing fast, portable and modular toolkit for Ethereum application development, written in Rust.
- Forge â Build, test, fuzz, debug and deploy Solidity contracts.
- Cast â Swiss Army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- Anvil â Fast local Ethereum development node.
- Chisel â Fast, utilitarian and verbose Solidity REPL.

Installation
curl -L https://foundry.paradigm.xyz | bash
foundryup
See the installation guide for more details.
To verify a downloaded release archive or container image, see Verifying Releases.
Getting Started
Initialize a new project, build and test:
forge init counter && cd counter
forge build
forge test
Interact with a live network:
cast block-number --rpc-url https://eth.merkle.io
cast balance vitalik.eth --ether --rpc-url https://eth.merkle.io
Fork mainnet locally:
anvil --fork-url https://eth.merkle.io
Read the Foundry Docs to learn more.
Contributing
Contributions are welcome and highly appreciated. To get started, check out the contributing guidelines.
Join our Telegram to chat about the development of Foundry.
Support
Having trouble? Check the Foundry Docs, join the support Telegram, or open an issue.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Top Related Projects
Dapp, Seth, Hevm, and more
:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
OpenZeppelin Contracts is a library for secure smart contract development.
Mythril is a symbolic-execution-based securty analysis tool for EVM bytecode. It detects security vulnerabilities in smart contracts built for Ethereum and other EVM-compatible blockchains.
Static Analyzer for Solidity and Vyper
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot