Skip to content

Repository files navigation

LazerForge Logo

LazerForge

LazerForge is a Foundry template for smart contract development. For more information on Foundry check out the foundry book.

Overview

LazerForge is a batteries included template with the following configurations:

  • Dependencies managed with Soldeer — declared in foundry.toml and version-locked in soldeer.lock, so they can be added, removed, and upgraded with a single command
  • forge fmt configured as the default formatter for VSCode projects
  • Github Actions workflows that run forge fmt --check, forge test, forge snapshot --check, and forge coverage on every push and PR. Soldeer dependencies and Forge artifacts are cached across runs.
    • A separate action to automatically fix formatting issues on PRs by commenting !fix on the PR
  • A justfile with the common Foundry recipes (just --list)
  • A pre-configured, but still minimal foundry.toml
    • multiple profiles for various development and testing scenarios
    • 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

Quick Start

  1. Install Foundry:
curl -L https://foundry.paradigm.xyz | bash
foundryup
  1. Create a new project using one of the templates:

Full repo with example contracts, Uniswap dependencies, and docs:

forge init --template lazertechnologies/lazerforge <project_name>

Minimal repo with just optimized config:

forge init --template lazertechnologies/lazerforge --branch variant/minimal <project_name>
  • DeFi Starter: 🚧 coming soon (--branch variant/defi)
  • NFT Starter: 🚧 coming soon (--branch variant/nft)
  • Stablecoin Starter: 🚧 coming soon (--branch variant/stablecoin)
  • Cross-Chain starter: 🚧 coming soon (--branch variant/cross-chain)
  1. Install dependencies:
forge soldeer install
  1. Build the project:
forge build

Branch Structure

  • main: Contains tutorials, additional example contracts, and comprehensive dependencies.
  • variant/*: Lighter starting points, currently variant/minimal — a lightweight template without extra tutorials and dependencies.

Everything under variant/ is generated from main — a build artifact described by a manifest in variants/ on main and rebuilt by CI on every push. Contributors only ever work on main.

For detailed info on branches and contribution, check out the Contributing Guide.

Dependencies

Dependencies are managed with Soldeer. They are declared in the [dependencies] section of foundry.toml and pinned by version and content hash in soldeer.lock. The dependencies/ directory itself is generated and git-ignored, so a fresh clone needs one command before it will build:

forge soldeer install

Run the same command after pulling changes that touch foundry.toml, or after switching branches.

To add, remove, or upgrade a dependency:

forge soldeer install <name>~<version>   # add
forge soldeer uninstall <name>           # remove
forge soldeer update                     # upgrade within declared ranges

Remappings are maintained by hand in foundry.toml rather than generated, so the template can keep import aliases like @openzeppelin/contracts/. The paths include the version number — update the matching remapping whenever you change a dependency's version.

The Uniswap aliases resolve to the package root, matching the import paths in Uniswap's own documentation. These packages import each other by their full published path, so the alias cannot point any deeper:

import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";

Commands

Common tasks live in the justfile. Install just, then run just (or just --list) to see them:

just build            # forge build (src/ only)
just test             # forge test (src/ only)
just fmt              # forge fmt
just lint             # forge lint
just cov              # coverage summary + HTML report

The demo contracts under examples/ build and test through their own profile:

just examples-build   # demo contracts under examples/
just examples-test    # demo tests
just snapshot         # gas snapshot for examples

Anything not covered by a recipe takes FOUNDRY_PROFILE=examples directly. CI checks the gas snapshot for these on every PR.

Recipes accept extra flags (just test --match-test test_Increment). just cov needs lcov (brew install lcov on macOS) and uses a [profile.coverage] with the optimizer off so instrumentation does not hit "stack too deep". CI uploads lcov.info as a workflow artifact.

Documentation

For detailed guides on various aspects of LazerForge, check out:

About

Foundry templates and tutorials for all Solidity developers

Topics

Resources

Contributing

Stars

6 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages