Forge is flexible on how you structure your project. By default, the structure is:
. ├── foundry.toml ├── lib │ └── forge-std │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── foundry.toml │ ├── lib │ └── src ├── script │ └── Counter.s.sol ├── src │ └── Counter.sol └── test └── Counter.t.sol 7 directories, 8 files
- You can configure Foundry's behavior using
- Remappings are specified in
- The default directory for contracts is
- The default directory for tests is
test/, where any contract with a function that starts with
testis considered to be a test.
- Dependencies are stored as git submodules in
You can configure where Forge looks for both dependencies and contracts using the
--contracts flags respectively. Alternatively you can configure it in
Combined with remappings, this gives you the flexibility needed to support the project structure of other toolchains such as Hardhat and Truffle.
For automatic Hardhat support you can also pass the
--hh flag, which sets the following flags:
--lib-paths node_modules --contracts contracts.