fork

Create a local anvil-zksync node pre-loaded with live state from a remote network. All subsequent transactions are mined locally, so you can experiment freely without touching the real chain.

Synopsis

anvil-zksync fork --fork-url <FORK_URL> [OPTIONS]

--fork-url is required. It accepts either an HTTP/S endpoint or a short-hand alias such as: mainnet, sepolia-testnet, abstract, etc.

Named chain aliases

AliasRPC endpoint
era, mainnethttps://mainnet.era.zksync.io
era-testnet, sepolia-testnethttps://sepolia.era.zksync.dev
abstracthttps://api.mainnet.abs.xyz
abstract-testnethttps://api.testnet.abs.xyz
sophonhttps://rpc.sophon.xyz
sophon-testnethttps://rpc.testnet.sophon.xyz
cronoshttps://mainnet.zkevm.cronos.org
cronos-testnethttps://testnet.zkevm.cronos.org
lenshttps://rpc.lens.xyz
lens-testnethttps://rpc.testnet.lens.xyz
openzkhttps://rpc.openzk.net
openzk-testnethttps://openzk-testnet.rpc.caldera.xyz/http
wonderchain-testnethttps://rpc.testnet.wonderchain.org
zkcandyhttps://rpc.zkcandy.io

Options

FlagDescription
--fork-url <FORK_URL>Network to fork from (HTTP/S endpoint or alias). Required.
--fork-block-number <BLOCK>Import state at a specific block number.
--fork-transaction-hash <HASH>Import state just before a given transaction.

Behavior

  • The forked state is loaded once at startup; changes made locally never propagate back to the remote network.
  • If neither --fork-block-number nor --fork-transaction-hash is supplied, anvil-zksync fetches the latest block.
  • All global flags (logging, gas, cache, etc.) still apply.

Examples

1. Fork Era mainnet at the latest block

anvil-zksync fork --fork-url mainnet

2. Fork a local node over HTTP

anvil-zksync fork --fork-url http://127.0.0.1:3050

3. Fork mainnet at block 59,473,098

anvil-zksync fork --fork-url mainnet --fork-block-number 59473098

4. Fork Abstract

anvil-zksync fork --fork-url abstract

See also

  • run — start a clean chain
  • replay_tx — fork & replay a specific transaction
  • CLI Overview — global flags and usage