Working on an Existing Project
Foundry makes developing with existing projects have no overhead.
For this example, we will use PaulRBerg’s
foundry-template
.
First, clone the project and run forge install
inside the project directory.
$ git clone https://github.com/PaulRBerg/foundry-template
$ cd foundry-template
$ forge install
$ bun install # install Solhint, Prettier, and other Node.js deps
We run forge install
to install the submodule dependencies that are in the project.
To build, use forge build
:
$ forge build --zksync
Compiling 28 files with zksolc and solc 0.8.25
zksolc and solc 0.8.25 finished in 4.68s
Compiler run successful!
And to test, use forge test
:
$ forge test --zksync
Compiling 25 files with Solc 0.8.25
Solc 0.8.25 finished in 925.41ms
Compiler run successful!
No files changed, compilation skipped
Ran 3 tests for test/Foo.t.sol:FooTest
[PASS] testFork_Example() (gas: 3779)
[PASS] testFuzz_Example(uint256) (runs: 1000, μ: 213166, ~: 213166)
[PASS] test_Example() (gas: 215916)
Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 5.69s (5.69s CPU time)
Ran 1 test suite in 5.69s (5.69s CPU time): 3 tests passed, 0 failed, 0 skipped (3 total tests)