Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Multi-File Projects

A project.yaml describes a multi-file Cambrian project: which .cam sources to load, which backend to target, where to write output, and optional test / Foundry / Lean knobs.

CLI

cambrian-transpiler --project path/to/project.yaml

Entry sources listed under sources: are merged into one program. Transitive import "./other.cam" edges are followed automatically — shared helper files need not be enumerated. Optional library_paths: / imports: pull helpers from a search root (for example the contract standard library) without listing them as project entries.

Minimal example

name: uniswap-v2
target: evm
output_dir: build/
sources:
  - ERC20.cam
  - UniswapV2Pair.cam
  - UniswapV2Factory.cam

Common keys

KeyRole
nameProject name (informational / packaging)
targetBackend: typically evm or lean
sourcesEntry-point .cam files (relative to the YAML)
library_pathsOptional extra directories to search for shared .cam files (${VAR} expanded; absolute or relative to the YAML). None are built in.
importsShared declaration files to load (helpers, not entities). Looked up next to the YAML, then in each library_paths directory. Names join the same program-wide namespace.
output_dirWhere generated code is written (default build/)
foundryFoundry / solc options (optimizer, via_ir, remappings, …)
fuzzShared fuzz defaults (runs, seed, shrink, …)
invariantShared invariant defaults (runs, depth, fail_on_revert, …)
leanLean-target knobs (numerics, proof_helpers, intrinsics, …)

Foundry remappings

When using @solidity_import on an extern entity:

foundry:
  optimizer: true
  via_ir: true
  remappings:
    - "@openzeppelin/=lib/openzeppelin-contracts/"
    - "forge-std/=lib/forge-std/src/"

Tests

fuzz:
  runs: 64
  seed: 1
  shrink: true

invariant:
  runs: 16
  depth: 16
  fail_on_revert: false

Imports vs project sources

  • sources: — entities and their tests, fuzz, and invariants. These are the files you own and deploy.
  • imports: — shared helpers listed in YAML (pure fn, types, library, event / error, extern entity, …). Looked up next to the YAML, then in each library_paths directory.
  • import "./lib.cam" — always relative to the importing file. A missing file is an ordinary “file not found”; library_paths is not searched.
  • import "token/erc20-core.cam" (no ./ / ../) — same directory as the importer first, then each library_paths entry.
  • An imported file must not declare entity, test, fuzz, or invariant — put those on sources:. Imported names are not wrapped in a package; a clash is the same duplicate-name error as two declarations in one file.
library_paths:
  - ${CAMBRIAN_STDLIB}
imports:
  - math.cam
  - token/erc20-core.cam

See Program Structure, project.yaml, and the Contract Standard Library.

Full key list

For the complete schema (including nested Foundry profiles and Lean emission options), see the reference page project.yaml.