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 .
.
├── lib
│ └── ds-test
└── src
├── Contract.sol
└── test
└── Contract.t.sol
6 directories, 7 files
We can build the project:
$ forge build
compiling...
success.
And run the tests:
$ forge test
compiling...
no files changed, compilation skipped.
Running 1 test for ContractTest.json:ContractTest
[PASS] testExample() (gas: 254)
💡 Tip
You can always print help for any subcommand (or their subcommands) by adding
--help
at the end.