A fast local Ethereum development node Examples: - anvil (start a local node on 127.0.0.1:8545) - anvil --fork-url $RPC_URL (fork the latest state of a live network) - anvil --block-time 12 (mine a new block every 12 seconds) - anvil --state state.json (load state if it exists and dump it on exit) Usage: anvil [OPTIONS] [COMMAND] Commands: completions Generate shell completions script [alias: com] help Print this message or the help of the given subcommand(s) Options: -a, --accounts Number of dev accounts to generate and configure [default: 10] -b, --block-time Block time in seconds for interval mining [alias: --blockTime] --balance The balance of every dev account in Ether [default: 10000] --config-out Writes output of `anvil` as json to user-specified file --derivation-path Sets the derivation path of the child key to be derived. [default: m/44'/60'/0'/0/] --dump-state Dump the state and block environment of chain on exit to the given file. If the value is a directory, the state will be written to `/state.json`. --fund-accounts ... Fund specific accounts with custom balances on startup. Accepts multiple address:balance pairs where balance is in ETH. Example: --fund-accounts 0x1234...5678:1000 0xabcd...ef01:5000 -h, --help Print help (see a summary with '-h') --hardfork The EVM hardfork to use. Choose the hardfork by name, e.g. `prague`, `cancun`, `shanghai`, `paris`, `london`, etc... [default: latest] --init Initialize the genesis block with the given `genesis.json` file --ipc [] Launch an ipc server at the given path or default path = `/tmp/anvil.ipc` [alias: --ipcpath] -j, --threads Number of threads to use. Specifying 0 defaults to the number of logical cores [alias: --jobs] --load-state Initialize the chain from a previously saved state snapshot -m, --mnemonic BIP39 mnemonic phrase used for generating accounts. Cannot be used if `mnemonic_random` or `mnemonic_seed` are used --max-persisted-states Max number of states to persist on disk. Note that `prune_history` will overwrite `max_persisted_states` to 0. --max-transactions Maximum number of transactions in a block --mixed-mining Enable mixed mining mode. Blocks are mined on a timer (set by `--block-time`), but also whenever a transaction is submitted. Requires `--block-time` to be set --mnemonic-random [] Automatically generates a BIP39 mnemonic phrase, and derives accounts from it. Cannot be used with other `mnemonic` options. You can specify the number of words you want in the mnemonic. [default: 12] --mnemonic-seed-unsafe Generates a BIP39 mnemonic phrase from a given seed Cannot be used with other `mnemonic` options. CAREFUL: This is NOT SAFE and should only be used for testing. Never use the private keys generated in production. --no-mining Disable auto and interval mining, and mine on demand instead [alias: --no-mine] --number The number of the genesis block --order How transactions are sorted in the mempool [default: fees] -p, --port Port number to listen on [default: 8545] --preserve-historical-states Preserve historical state snapshots when dumping the state. This will save the in-memory states of the chain at particular block hashes. These historical states will be loaded into the memory when `--load-state` / `--state`, and aids in RPC calls beyond the block at which state was dumped. --profile The configuration profile to use --prune-history [] Don't keep full chain history. If a number argument is specified, at most this number of states is kept in memory. If enabled, no state will be persisted on disk, so `max_persisted_states` will be 0. -s, --state-interval Interval in seconds at which the state and block environment is to be dumped to disk. See --state and --dump-state --slots-in-an-epoch Slots in an epoch [default: 32] --state This is an alias for both --load-state and --dump-state. It initializes the chain with the state and block environment stored at the file, if it exists, and dumps the chain's state on exit. --tempo.consensus-seed Development consensus seed for Tempo, as 32 bytes of hex. Defaults to a domain-separated hash of the dev-account mnemonic. Only used on Tempo networks. --tempo.epoch-length Number of block heights in a Tempo consensus epoch. Only used on Tempo networks [default: 21600] --tempo.fee-payer
The account used to sponsor Tempo fee-payer requests (`eth_signRawTransaction` and raw transactions carrying the sponsorship placeholder). Must be an unlocked account. Only used on Tempo networks; defaults to the last dev account. --timestamp The timestamp of the genesis block --transaction-block-keeper Number of blocks with transactions to keep in memory --transaction-coalescing-window Time in milliseconds to group ready transactions into one auto-mined block. Defaults to 0 (no delay). Set a positive value to enable transaction coalescing [default: 0] -V, --version Print version Display options: --color The color of the log messages Possible values: - auto: Intelligently guess whether to use color output (default) - always: Force color output - never: Force disable color output --json Format log messages as JSON --md Format log messages as Markdown -q, --quiet Do not print log messages -v, --verbosity... Verbosity level of the log messages. Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). Depending on the context the verbosity levels have different meanings. For example, the verbosity levels of the EVM are: - 2 (-vv): Print logs for all tests. - 3 (-vvv): Print execution traces for failing tests. - 4 (-vvvv): Print execution traces for all tests, and setup traces for failing tests. - 5 (-vvvvv): Print execution and setup traces for all tests, including storage changes and backtraces with line numbers. Server options: --allow-origin The cors `allow_origin` header [default: *] --cache-path Path to the cache directory where persisted states are stored (see `--max-persisted-states`). Note: This does not affect the fork RPC cache location, which uses endpoint-specific files under `~/.foundry/cache/rpc///`. --host The hosts the server will listen on [env: ANVIL_IP_ADDR=] [default: 127.0.0.1] --no-cors Disable CORS --no-request-size-limit Disable the default request body size limit. At time of writing the default limit is 2MB Fork config: --compute-units-per-second Sets the number of assumed available compute units per second for this provider default value: 330 See also --fork-url and -f, --fork-url Fetch state over a remote endpoint instead of starting from an empty state. If you want to fetch state from a specific block number, add a block number like `http://localhost:8545@1400000` or use the `--fork-block-number` argument. Multiple `--fork-url` flags can be provided to distribute requests across endpoints using round-robin load balancing. On failure, the retry layer rotates to the next endpoint. [alias: --rpc-url] --fork-block-number Fetch state from a specific block number over a remote endpoint. If negative, the given value is subtracted from the `latest` block number. See --fork-url. --fork-chain-id Specify chain id to skip fetching it from remote endpoint. This enables offline-start mode. You still must pass both `--fork-url` and `--fork-block-number`, and already have your required state cached on disk, anything missing locally would be fetched from the remote. --fork-header Headers to use for the rpc client, e.g. "User-Agent: test-agent" See --fork-url. --fork-retry-backoff Initial retry backoff on encountering errors. See --fork-url. --fork-state-by-number Read fork state by block number instead of by block hash. Use this for RPCs that cannot serve `eth_getBalance`, `eth_getCode`, `eth_getStorageAt` or `eth_getTransactionCount` for a block hash. Block hash ancestry is still validated against the fork block. See --fork-url. --fork-transaction-hash Fetch state from after a specific transaction hash has been applied over a remote endpoint. See --fork-url. --no-bal Disable pre-filling the fork cache with block access list (BAL) post-state. By default, eligible Ethereum forks briefly try fetching a BAL at the fork block. Missing or invalid BALs fall back to ordinary state reads. This setting also applies to subsequent resets and does not disable serving BAL RPC methods. --no-fork-node-info Do not probe the fork endpoint with `anvil_nodeInfo` / `anvil_metadata`. Those calls detect a nested Anvil. Some public RPCs retry unknown methods for tens of seconds instead of returning method-not-found, which delays listen until the probe finishes. --no-rate-limit Disables rate limiting for this node's provider. default value: false See also --fork-url and [alias: --no-rpc-rate-limit] --no-storage-caching Explicitly disables the use of RPC caching. All storage slots are read entirely from the endpoint. This flag overrides the project's configuration file. See --fork-url. --retries Number of retry requests for spurious networks (timed out requests) Default value 5 --timeout Timeout in ms for requests sent to remote JSON-RPC server in forking mode. Default value 45000 Environment config: --block-base-fee-per-gas The base fee in a block [alias: --base-fee] --chain-id The chain ID --code-size-limit EIP-170: Contract code size limit in bytes. Useful to increase this because of tests. To disable entirely, use `--disable-code-size-limit`. By default, it is 0x6000 (~25kb) --disable-block-gas-limit Disable the `call.gas_limit <= block.gas_limit` constraint --disable-code-size-limit Disable EIP-170: Contract code size limit --disable-min-priority-fee Disable the enforcement of a minimum suggested priority fee [alias: --no-priority-fee] --enable-tx-gas-limit Enable the transaction gas limit check as imposed by EIP-7825 (Osaka hardfork). From Amsterdam, the cap always applies to regular gas only, and gas above it becomes the EIP-8037 state gas reservoir. [alias: --tx-gas-limit] --gas-limit The block gas limit --gas-price The gas price EVM options: --auto-impersonate Enables automatic impersonation on startup. This allows any transaction sender to be simulated as different accounts, which is useful for testing contract behavior [alias: --auto-unlock] --disable-console-log Disable printing of `console.log` invocations to stdout [alias: --no-console-log] --disable-default-create2-deployer Disable the default create2 deployer [alias: --no-create2] --disable-pool-balance-checks Disable pool balance checks --memory-limit The memory limit per EVM execution in bytes --print-traces Enable printing of traces for executed transactions and `eth_call` to stdout [alias: --enable-trace-printing] --steps-tracing Enable steps tracing used for debug calls returning geth-style traces Steps are recorded by replaying the transaction from its parent block's state, so they are unavailable once that state is pruned or when loading a state dump created without `--preserve-historical-states`. [alias: --tracing] Networks: --celo Enable Celo network features -n, --network Enable a specific network family [possible values: ethereum, optimism, tempo, monad]