LazerForge is a Foundry template for smart contract development. For more information on Foundry check out the foundry book.
LazerForge is a batteries included template with the following configurations:
- OpenZeppelin, Solady, and the full Uniswap suite (v2, v3-core & v3-periphery, v4-core & v4-periphery) smart contracts are included as dependencies along with
solc
remappings so you can work with a wide range of deployed contracts out of the box! forge fmt
configured as the default formatter for VSCode projects- Github Actions workflows that run
forge fmt --check
andforge test
on every push and PR- A separate action to automatically fix formatting issues on PRs by commenting
!fix
on the PR
- A separate action to automatically fix formatting issues on PRs by commenting
- A pre-configured, but still minimal
foundry.toml
- multiple profiles for various development and testing scenarios (see LazerForge Profiles)
- high optimizer settings by default for gas-efficient smart contracts
- an explicit
solc
compiler version for reproducible builds - no extra injected
solc
metadata for simpler Etherscan verification and deterministic cross-chain deploys via CREATE2. - block height and timestamp variables for deterministic testing
- mapped network identifiers to RPC URLs and Etherscan API keys using environment variables
- Install Foundry:
curl -L https://foundry.paradigm.xyz | bash
foundryup
- Create a new project:
forge init --template lazertechnologies/lazerforge <project_name>
💡 To install a minimal template without tutorials and extra dependencies:
forge init --template lazertechnologies/lazerforge --branch minimal <project_name>
- Build the project:
forge build
LazerForge maintains two primary branches to cater to different needs:
main
Branch: Contains tutorials, additional example contracts, and comprehensive dependencies.minimal
Branch: Provides a lightweight template without extra tutorials and dependencies.
For detailed info on branches and contribution, check out the Contributing Guide.
We use a dedicated synchronization workflow to maintain consistency between branches while respecting their different purposes.
To sync changes from main
to minimal
:
- Ensure your changes are merged to
main
first - Run the sync script:
./tools/sync-to-minimal.sh
-
The script will:
- Update a dedicated sync branch with the latest from
main
- Open a PR creation page targeting
minimal
- Update a dedicated sync branch with the latest from
-
During PR review:
- Verify only appropriate files are included
- Exclude tutorial content or other files not needed in
minimal
For emergency fixes in minimal
:
If you need to make a hotfix directly to minimal
and then sync back to main
:
- Make and merge your changes to
minimal
- Run:
./tools/sync-to-main.sh
- Complete a PR to sync these changes back to
main
Always make feature development PRs to
main
first, and use the sync scripts rather than manually cherry-picking to maintain consistency.
For detailed guides on various aspects of LazerForge, check out:
- Setup Guide - Initial setup and configuration
- Testing Guide - Writing and running tests
- Deployment Guide - Deploying contracts
- Network Configuration - Setting up networks and RPC endpoints
- Profiles - Using different Foundry profiles
When working across branches with different dependencies, submodules may need to be reinitialized. Run
./reinit-submodules
Forge can generate gas snapshots for all test functions to see how much gas contracts will consume, or to compare gas usage before and after optimizations.
forge snapshot
If you plan on generating coverage reports, you'll need to install lcov
as well.
On macOS, you can do this with the following command:
brew install lcov
To generate reports, run
./coverage-report