replay_tx

Spin up an anvil-zksync node that forks a remote network and immediately re-executes a chosen L2 transaction.

Perfect for step-through debugging or gas cost inspection of real world transactions and contract interactions.

Synopsis

anvil-zksync replay_tx --fork-url <FORK_URL> <TX>

Both parameters are required:

  • --fork-url <FORK_URL> - remote endpoint or chain alias
  • <TX> - L2 transaction hash to replay

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

Arguments

NameDescription
<TX>Transaction hash (0x…, 32 bytes). Required.

Options

FlagDescription
--fork-url <FORK_URL>Network to fork from (endpoint or alias). Required.

All global flags (verbosity, cache, gas tuning, etc.) are also available.

Behavior

  1. Downloads block state up to (but not including) <TX>.
  2. Replays the transaction locally, reproducing calldata & timestamp.
  3. Provides full VM traces, logs, and storage-diff when -vv or higher is enabled.

Examples

1. Replay a swap transaction from Era mainnet

anvil-zksync replay_tx \
  --fork-url mainnet \
  0xe56fd585309971c7c68b19c6c75a39c4b450731f9884c7b73e13276bb6db9b5b

2. Replay a tx from a local node

anvil-zksync replay_tx \
  --fork-url http://127.0.0.1:3050 \
  0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef

3. Replay a failed transaction with user VM tracing

anvil-zksync -vv replay_tx \
  --fork-url mainnet \
  0x9419f4eb8d553dd4f4d254badfd28efb0b2416c4b0eb26076f90e1226501a3e0

See also

  • fork — fork without replay
  • run — fresh, empty chain
  • CLI overview — global flags and usage