First Steps with Foundry

This section provides an overview of the forge command line tool. We demonstrate how to create a new project, compile, and test it.

To start a new project with Foundry, use forge init:

$ forge init hello_foundry

Let's check out what forge generated for us:

$ cd hello_foundry
$ tree . -d -L 1
.
├── lib
├── script
├── src
└── test

4 directories

We can build the project with forge build:

$ forge build
Compiling 7 files with 0.8.13
Compiler run successful

And run the tests with forge test:

$ forge test
No files changed, compilation skipped

Running 1 test for test/Contract.t.sol:ContractTest
[PASS] testExample() (gas: 279)
Test result: ok. 1 passed; 0 failed; finished in 599.09µs

💡 Tip

You can always print help for any subcommand (or their subcommands) by adding --help at the end.