Skip to main content

Signing: anvil-signed vs. locally signed

Signed by anvilSigned locally
Howeth_sendTransaction from an unlocked addresseth_sendRawTransaction with a key in the client
Accountsdev accounts, impersonated addresses, autoImpersonate()withLocalAccount(), testClientFor(privateKeyToAccount(key))
Reverting writessent as-is, mined, receipt status: "reverted"viem estimates gas first: the decoded revert is thrown, nothing is sent
After setChainId()fail: anvil's signer keeps the startup chain idwork
Keys needednoyes: from the mnemonic, the banner, or your own

To assert a revert reason, simulate or sign locally; to test what happens on chain, send anvil-signed and check the receipt (confirm()).

Where local keys come from​

  • Default mnemonic: built in. withMnemonic(): derived once.
  • Random or seeded mnemonic: read from anvil's banner, so not with logs.quiet() (withLocalAccount(index) is then rejected before start).

withAccount(address, { impersonate: true })​

anvil signs only for dev accounts and impersonated addresses: a non-dev default address needs { impersonate: true } or account.autoImpersonate(), or prepare() rejects it.

Related: Sign locally, Assert reverts.