A catered template of https://github.com/FrankieIsLost/forge-template.
A template for quickly getting started with forge
If you don't have forge installed:
curl -L https://foundry.paradigm.xyz | bash
foundryup
brew install libusb
- then forge should be intalled
mkdir my-project
cd my-project
forge init --template https://github.com/DeGatchi/forge-contract
npm install ## install development dependencies
forge build
forge test
Terminal: forge flatten ./src/[folder]/[contract].sol
Pipe into contract: forge flatten ./src/[folder]/[contract].sol > output.sol
When adjusting the contract being tested you may need to compile from scratch. Sometimes forge bugs out and doesn't recompile properly.
forge clean && forge test -vvv
-v
,-vv
,-vvv
,-vvvv
: each v increases the details returned from the test (I usually use-vvv
&-vvvv
)forge test -vvv --match--contract <CONTRACT_NAME>
: tests a single contract (don't put.t.sol
or.sol
at the end).
hevm.warp(uint256)
: sets block.timestamp touint256
hevm.prank(address)
: sets msg.sender toaddress
for 1 txhevm.startPrank(address)
: sets msg.sender toaddress
untilhevm.stopPrank()
hevm.stopPrank()
: stops msg.sender beingaddress
Includes common testing contracts like Hevm.sol
and Console.sol
, as well as a Utilities.sol
contract with common testing methods like creating users with an initial balance.
ds-test
, solmate
+ openzeppelin
are already installed.
Installed for the truffle flattener b/c Forge isn't compatible w/ chain deployments separate from Ethereum.
Pre-configured solhint
and prettier-plugin-solidity
. Can be run by
npm run solhint
npm run prettier
Automatically run linting and tests on pull requests.
Including .gitignore
, .vscode
, remappings.txt
This project is open-sourced software licensed under the GNU Affero GPL v3.0 license. See the License file for more information.