Skip to content

Commands

Andrei Vlad Birgaoanu edited this page Mar 18, 2024 · 2 revisions

This is a list of the most frequently needed commands.

Build

Build the contracts using the default profile:

$ forge build

Build Optimized

Build the contracts using the optimized profile:

$ bun build:optimized

This will compile the contracts with the --via-ir flag enabled.

Build SMT

Build the contracts with the SMTChecker enabled, while ignoring any warnings due to the use of assembly blocks:

$ bun build:smt

This will attempt to formally prove the correctness of the contracts by trying to break invariants (e.g. by finding failing assert statements).

Clean

Delete the build artifacts and cache directories:

$ forge clean

Format

Format the code:

$ forge fmt

Gas Report

Get a gas report:

$ bun gas:report

Gas Report Optimized

Get a gas report for the optimized version of the contracts:

$ bun gas:report:optimized

Gas Snapshot

Take a gas snapshot:

$ bun gas:snapshot

Gas Snapshot Optimized

Take a gas snapshot against the optimized version of the contracts:

$ bun gas:snapshot:optimized

Lint

Lint the entire code base (Solidity + other files):

$ bun lint

Lint Sol

Lint the contracts:

$ bun lint:sol

Test

Run the tests:

$ bun test

Test Optimized

Run the tests against the optimized version of the contracts:

$ bun test:optimized

Other

There are many other commands available in Foundry. Check out the Foundry Book!