What is Foundry?

Foundry is a toolkit for Ethereum development, written in Rust, in which you build, test and deploy Solidity contracts and write the tests in Solidity too (Foundry). Paradigm introduced it on 7 December 2021 as a reimplementation of the dapptools testing framework (Paradigm).

Last updated . 2 minute read. By the QuillAudits Team.

What are Forge, Cast, Anvil and Chisel?

Tool What it does
Forge Builds, tests, deploys and verifies contracts
Cast Calls contracts, sends transactions and reads chain data from the command line
Anvil Runs a local Ethereum node that can fork a live network
Chisel A Solidity REPL for trying out snippets

The descriptions come from the Foundry README and the Foundry docs.

What does a Foundry test look like?

Foundry tests are Solidity contracts in which setUp() runs before each test and test functions are prefixed with test (Foundry), and a test that takes parameters becomes a fuzz test.

A contract, a unit test and a fuzz test, with no imports (illustrative, not audited code) CounterTest.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

contract Counter {
    uint256 public count;

    function increment() external {
        count += 1;
    }
}

contract CounterTest {
    Counter internal counter;

    function setUp() public {
        counter = new Counter();
    }

    function test_incrementAddsOne() public {
        counter.increment();
        assert(counter.count() == 1);
    }

    function testFuzz_incrementTimes(uint8 times) public {
        for (uint256 i = 0; i < times; i++) counter.increment();
        assert(counter.count() == times);
    }
}

Real projects inherit from the forge-std Test contract, which adds assertions and cheatcodes that change msg.sender, balances, block time and storage inside a test (Foundry).

Why do security reviewers use Foundry?

The attack and the test are in the same language. A reviewer can write a proof of concept exploit as a test, run it on a fork of mainnet with forge test --fork-url (Foundry), and turn a property into an invariant test without leaving Solidity. QuillShield supports Solidity in Foundry projects today, and run your first audit shows the steps.

QuillShield is building the security layer between AI and money, so you can keep shipping between audits.

Sign-up is free, and new accounts get $50 in credit, good for up to half of an order.

  1. 1Sign up and import a repo
  2. 2See the exact price before anything is charged
  3. 3Approve it, and the audit starts