Foundry ZKsync is a ZKsync Era fork of Foundry for smart contract compilation, deployment,
testing, and interaction. This is a Rust monorepo (Cargo workspace) using make for automation.
crates/
forge/ Test framework + CLI commands (bin)
cast/ Contract interaction CLI (bin)
anvil/ Local Ethereum node (bin)
chisel/ Solidity REPL (bin)
cli/ Shared CLI infrastructure
script/ Forge script runner
evm/
core/ EVM backend, database, fork support
evm/ Executor + inspectors
traces/ Execution tracing + decoding
fuzz/ Fuzzing + invariant testing
coverage/ Code coverage
abi/ Solidity ABI utilities
networks/ Custom network features
cheatcodes/ Cheatcode inspector + strategy dispatch
common/ Shared types (expect, mock, record)
spec/ Cheatcode specifications
zksync/
core/ ZKsync VM, state, cheatcode tracers
compilers/ zksolc integration, dual compilation
inspectors/ ZKsync trace collection
strategy/zksync/ Strategy runners (cheatcode, executor, backend)
config/ Configuration (foundry.toml + ZkSyncConfig)
common/ Shared utilities, shell macros
verify/ Contract verification
linking/ Library linking
primitives/ Core types
testdata/ Standard Foundry test data
testdata_zk/ ZKsync-specific test data
docs-zksync/ ZKsync architecture + process docs
.agents/ Agent guides
cargo +nightly clippy -p <crate> -- -D warnings-- lint a single cratecargo +nightly fmt-- format Rustcargo nextest run -p <crate>-- test a single cratemake lint-- format + clippy + typos (whole workspace)make test-- all unit + doc testsmake pr-- full pre-push check (cargo deny + lint + test)make build-- build the project
- Touching
crates/forge/,crates/evm/,crates/cheatcodes/,crates/script/, orcrates/anvil/? Read Forge & EVM patterns first. - Touching any file with
zksyncin its path? Read ZKsync patterns first. - Performing an upstream Foundry merge? Read Upstream merge guide first.
- Plan changes and identify files you will touch. Ask for clarification if needed.
- Read the relevant domain guide (see pointers above).
- Check existing patterns in similar files before writing new code.
- Implement with minimal diff -- change only what's necessary, don't refactor adjacent code.
- Per modified crate:
cargo +nightly clippy -p <crate> -- -D warnings+cargo nextest run -p <crate>. - Before committing:
make pr. Verify no secrets are being committed. - Update docs if behavior changed.
- Commits -- conventional commits:
feat:,fix:,chore:,refactor:. - Output -- use
sh_println!/sh_eprintln!, neverprintln!/eprintln!(clippy enforces this). - ZKsync notes -- prefix with
NOTE(zk):when explaining divergence from upstream Foundry. - AI disclosure -- disclose AI assistance in PRs per
CONTRIBUTING.md. - Dependencies -- never add a new dep without checking if an existing crate covers the need.
- Forking tests -- test names must contain "fork" if they use forking.