anvil-zksync

A single binary local ZK chain node that can impersonate any ZKsync powered or Elastic Network ZK chain. Ideal for integration tests, fork based debugging, quick prototyping, and offline experiments.

Installation

brew tap matter-labs/anvil-zksync https://github.com/matter-labs/anvil-zksync.git 
brew install anvil-zksync

Usage

anvil-zksync [OPTIONS] [COMMAND]

Quick start

# 1. Fresh network that auto‑mines
anvil-zksync run -vv
# 2. Fork mainnet at the latest block
anvil-zksync fork mainnet
# 3. Replay tx from Abstract mainnet with user vm traces
anvil-zksync -vv replay_tx --fork-url abstract \
0xea5a45976f8013fd937ac267211fa575bc5968350a0ae3d8932bad75651d933c

Commands

CommandPurposeDocs
runStart a brand new empty networkrun
forkFork an existing chain into a local instancefork
replay_txFork + replay a historical L2 transactionreplay_tx
helpShow help for any command-

Global options

Chain initialization

FlagDescriptionDefault
--timestamp <NUM>Override genesis block timestamp-
--init <PATH>Load full genesis.json definition-
--state <PATH>Load then dump snapshot on exit-
-s, --state-interval <SECONDS>Auto-dump state every n seconds-
--dump-state <PATH>Dump state snapshot on exit only-
--preserve-historical-statesKeep in-memory states for past blocksoff
--load-state <PATH>Restore from an existing snapshot-

Mining & mempool

FlagDescriptionDefault
--no-miningMine on demand onlyauto-mine
--order <order>Transaction ordering strategyfifo

General

FlagDescription
--offlineDisable all network requests
--health-check-endpointExpose GET /health returning 200 OK
--config-out <FILE>Write effective JSON config to disk
-h, --helpShow help
-V, --versionShow version

Network

FlagDescriptionDefault
--port <PORT>RPC port8011
--host <IP>Bind address (env ANVIL_ZKSYNC_IP_ADDR)0.0.0.0
--chain-id <ID>Chain ID260

Debugging

FlagDescriptionValues / Notes
--show-node-config[=<bool>]Print node config on startuptrue
--show-storage-logs <mode>Storage log detailsnone, read, write, paid, all
--show-vm-details <mode>VM execution detailsnone, all
--show-gas-details <mode>Gas cost breakdownnone, all
-v, --verbosity…Increment log detail (-vvv = system + user traces)up to -vvvvv

Gas configuration

FlagDescription
--l1-gas-price <wei>Custom L1 gas price
--l2-gas-price <wei>Custom L2 gas price
--l1-pubdata-price <wei>Custom pubdata price
--price-scale-factor <x>Price estimation multiplier
--limit-scale-factor <x>Gas limit estimation multiplier

System

FlagDescriptionDefault / Values
--override-bytecodes-dir <DIR>Override deployed bytecodes-
--enforce-bytecode-compression=<bool>Enforce compressionfalse
--dev-system-contracts <mode>Built‑in / local / no-securitybuilt-in
--system-contracts-path <PATH>Custom system contract build-
--protocol-version <N>Protocol version for new blocks26
--evm-interpreterEnable EVM interpreterfalse

Logging

FlagDescriptionDefault
--log <level>Log levelinfo
--log-file-path <PATH>Persist logsanvil-zksync.log
--silent[=<bool>]Suppress startup bannerfalse

Cache

FlagDescriptionDefault
--cache <option>Cache backend. Available options: none, memory,diskdisk
--reset-cache=<bool>Wipe local cache on startfalse
--cache-dir <DIR>Cache directory.cache

Accounts

FlagDescriptionDefault
-a, --accounts <N>Dev accounts to generate10
--balance <ETH>Balance per dev account10000
--mnemonic <PHRASE>Custom BIP-39 mnemonic-
--mnemonic-random[=<words>]Generate random mnemonic12 words
--mnemonic-seed-unsafe <seed>Derive from seed (testing only)-
--derivation-path <path>HD derivation pathm/44'/60'/0'/0/
--auto-impersonateUnlock any sender (aka --auto-unlock)-

Block sealing

FlagDescriptionDefault
-b, --block-time <sec>Fixed block interval. If unset, seal instantly-

Server

FlagDescriptionDefault
--allow-origin <origins>CORS Access-Control-Allow-Origin*
--no-corsDisable CORS-

L1 (unstable)

FlagDescriptionDefault
--spawn-l1[=<port>]Start colocated L1 Anvil node8012
--external-l1 <URL>Use external L1 JSON-RPC-
--auto-execute-l1[=<bool>]Auto execute L1 batchesfalse

Custom base token

FlagDescription
--base-token-symbol <SYM>Replace ETH symbol
--base-token-ratio <ratio>Conversion ratio (40000, 628/17)

Next steps

  • Start a local chainrun
  • Fork Elastic Network chainsfork
  • Replay transactionreplay_tx