debug-trace

Spin up an anvil-zksync node that forks a remote network and attaches to the debug API for a given transaction.

Outputs either:

  • A formatted call trace (human-readable), or
  • The raw debug JSON (if requested).

Perfect for diagnosing why a transaction reverted, inspecting nested calls, or analyzing low-level VM execution.


Synopsis

anvil-zksync debug-trace --rpc-url <FORK_URL> <TX>

Both parameters are required:

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

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
zkcandyhttps://rpc.zkcandy.io

Arguments

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

Options

FlagDescription
--rpc-url <FORK_URL>Network to fork from (endpoint or alias). Required.
--only-topRestrict trace output to only the top-level call (skip internal calls).
--rawPrint raw debug JSON instead of formatted trace.

Behavior

  1. Queries the debug_traceTransaction RPC using the URL and TX provided.

  2. Depending on flags:

    • --only-top: prints only the root call.
    • --raw: dumps the raw JSON response.
    • Otherwise: prints a formatted tree trace with calls, gas, and status.

Examples

1. Debug a successful swap tx on Era mainnet

anvil-zksync debug-trace \
  --rpc-url mainnet \
  0x977b31d564042b7e14044c5d1fd7c1f95454e8f9ef643febd40a9c0d082d09cb

2. Show only the top-level call

anvil-zksync debug-trace \
  --rpc-url mainnet \
  --only-top \
  0x977b31d564042b7e14044c5d1fd7c1f95454e8f9ef643febd40a9c0d082d09cb

3. Dump the raw debug JSON

anvil-zksync debug-trace \
  --rpc-url mainnet \
  --raw \
  0x977b31d564042b7e14044c5d1fd7c1f95454e8f9ef643febd40a9c0d082d09cb

See also

  • replay_tx — fork & re-execute a transaction
  • fork — fork without replay
  • run — fresh, empty chain
  • CLI overview — global flags and usage