anvil_* namespace

Low level node controls that anvil-zksync exposes on top of the standard Ethereum RPC and zks RPC. They let devs mine blocks on demand, timetravel, impersonate accounts, edit balances/code, and tweak automine behaviour.

curl -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"anvil_mine","params":[]}'

Method index

Mining & mempool

Method✓ / ✗Purpose
anvil_mine✓Mine N blocks instantly
anvil_mine_detailed✓Mine & return extra data
anvil_dropTransaction✓Remove tx by hash
anvil_dropAllTransactions✓Clear mempool
anvil_removePoolTransactions✓Drop txs by sender

Automine & intervals

Method✓ / ✗Purpose
anvil_getAutomine✓Query automine
anvil_setAutomine✓Toggle automine
anvil_setIntervalMining✓Mine every N ms
anvil_setNextBlockBaseFeePerGas✓Next block base fee
anvil_setBlockTimestampInterval✓Auto timestamp +Δ
anvil_removeBlockTimestampInterval✓Clear timestamp Δ

State snapshots

Method✓ / ✗Purpose
anvil_snapshot✓Take snapshot
anvil_revert✓Revert to snapshot
anvil_reset✓Reset chain - fork aware

Time travel

Method✓ / ✗Purpose
anvil_setTime✓Set wall clock
anvil_increaseTime✓Jump forward Δ sec
anvil_setNextBlockTimestamp✓Timestamp of next block

Accounts & impersonation

Method✓ / ✗Purpose
anvil_impersonateAccount✓Start impersonation
anvil_stopImpersonatingAccount✓Stop impersonation
anvil_autoImpersonateAccount✓Toggle auto impersonate
anvil_setBalance✓Set balance
anvil_setCode✓Set bytecode
anvil_setStorageAt✓Set storage slot
anvil_setNonce✓Set nonce

Chain parameters & logging

Method✓ / ✗Purpose
anvil_setChainId✓Change chainId
anvil_setRpcUrl✓Hot swap fork URL
anvil_setLoggingEnabled✓Toggle RPC logging
anvil_setMinGasPrice✗(pre EIP-1559 only)

Method reference

Full schema lives in the Anvil docs ↗︎.

anvil_mine

Mine one or more blocks instantly.

# mine 1 block
curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"anvil_mine","params":[]}'
# mine 12 blocks
curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":2,"method":"anvil_mine","params":["0xc"]}'

anvil_mine_detailed

Same as anvil_mine but returns block hash, timestamp, gas used, etc.

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"anvil_mine_detailed","params":[]}'

anvil_getAutomine

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"anvil_getAutomine","params":[]}'

anvil_setAutomine

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"anvil_setAutomine","params":[false]}'

anvil_snapshot

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"anvil_snapshot","params":[]}'

Stores the snapshot ID returned. Revert with anvil_revert.

anvil_revert

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"anvil_revert","params":["0x1"]}'

Snapshot IDs are hex strings ("0x1", "0x2"…).

anvil_impersonateAccount

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"anvil_impersonateAccount","params":["0x…addr…"]}'

anvil_setBalance

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{
        "jsonrpc":"2.0","id":1,"method":"anvil_setBalance",
        "params":["0x…addr…", "0x8AC7230489E80000"]  // 10 ETH
      }'

anvil_setRpcUrl

Hot swap the upstream fork URL (must be same chain).

curl -s -X POST http://localhost:8011 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"anvil_setRpcUrl","params":["https://mainnet.era.zksync.io"]}'

Unimplemented stubs

The following method is not yet implemented and will return Method not found:

  • anvil_setMinGasPrice

See also

  • eth_* — Ethereum compatible base methods
  • hardhat_* — Hardhat style helpers
  • zks_* — ZKsync specific extensions