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_mineMine N blocks instantly
anvil_mine_detailedMine & return extra data
anvil_dropTransactionRemove tx by hash
anvil_dropAllTransactionsClear mempool
anvil_removePoolTransactionsDrop txs by sender

Automine & intervals

Method✓ / ✗Purpose
anvil_getAutomineQuery automine
anvil_setAutomineToggle automine
anvil_setIntervalMiningMine every N ms
anvil_setNextBlockBaseFeePerGasNext block base fee
anvil_setBlockTimestampIntervalAuto timestamp +Δ
anvil_removeBlockTimestampIntervalClear timestamp Δ

State snapshots

Method✓ / ✗Purpose
anvil_snapshotTake snapshot
anvil_revertRevert to snapshot
anvil_resetReset chain - fork aware

Time travel

Method✓ / ✗Purpose
anvil_setTimeSet wall clock
anvil_increaseTimeJump forward Δ sec
anvil_setNextBlockTimestampTimestamp of next block

Accounts & impersonation

Method✓ / ✗Purpose
anvil_impersonateAccountStart impersonation
anvil_stopImpersonatingAccountStop impersonation
anvil_autoImpersonateAccountToggle auto impersonate
anvil_setBalanceSet balance
anvil_setCodeSet bytecode
anvil_setStorageAtSet storage slot
anvil_setNonceSet nonce

Chain parameters & logging

Method✓ / ✗Purpose
anvil_setChainIdChange chainId
anvil_setRpcUrlHot swap fork URL
anvil_setLoggingEnabledToggle 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