> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.getfoundry.sh/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

## Testing

Configuration related to the behavior of `forge test`.

**Sections**

* [General](/config/reference/testing#general)
* [Fuzz](/config/reference/testing#fuzz)
* [Invariant](/config/reference/testing#invariant)

### General

#### `verbosity`

* Type: integer
* Default: `0`
* Environment: `FOUNDRY_VERBOSITY`, `DAPP_VERBOSITY`, or `DAPP_TEST_VERBOSITY`

Default verbosity for test and script output, as if passed with `-v` flags.

* `2` (`-vv`): logs emitted during tests are displayed.
* `3` (`-vvv`): execution traces of failing tests are displayed.
* `4` (`-vvvv`): execution traces of all tests, and setup traces of failing tests, are
  displayed.
* `5` (`-vvvvv`): execution and setup traces are always displayed, including storage
  changes and backtraces with line numbers.

`-v` flags on the command line replace this value. Trace rendering uses the higher of this
value and `verbosity` in the `tracing` section.

#### `ffi`

* Type: boolean
* Default: `false`

Whether to allow the `vm.ffi` and `vm.tryFfi` cheatcodes to run external commands.

**Warning:** enabling this lets tests and scripts run arbitrary programs on your machine
with your user's permissions. Only enable it for code you trust, including its
dependencies.

Commands run from the project root, and `vm.ffi` returns their standard output, hex-decoded
when it is valid hex. Enable it here, with inline config, or for one run with `--ffi`; the
`FOUNDRY_FFI` and `DAPP_FFI` environment variables are ignored. Mutation testing refuses to
run while it is enabled.

#### `sender`

* Type: string (address)
* Default: `"0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38"`
* Environment: `FOUNDRY_SENDER`, `DAPP_SENDER`, `DAPP_TEST_SENDER`, or `DAPP_TEST_ADDRESS`

The address that deploys test contracts and calls test functions, and the default script
sender.

In `forge test`, this address deploys each test contract and calls `setUp` and the test
functions, so it is `msg.sender` for those calls; its balance is set to `initial_balance`.
In `forge script`, it is the sender unless `--sender`, a private key, or a single
configured wallet determines another. The `--sender` flag overrides it.

#### `tx_origin`

* Type: string (address)
* Default: `"0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38"`
* Environment: `FOUNDRY_TX_ORIGIN`, `DAPP_TX_ORIGIN`, or `DAPP_TEST_TX_ORIGIN`

The `tx.origin` value for EVM execution.

Foundry currently does not apply this value: in tests and scripts, `tx.origin` is the
account that sends each top-level call, which is `sender` unless a prank or broadcast
changes it. Use `vm.prank(sender, origin)` or `vm.startPrank(sender, origin)` to set
`tx.origin` for specific calls.

#### `initial_balance`

* Type: string (decimal or hex integer)
* Default: `"0xffffffffffffffffffffffff"`
* Environment: `FOUNDRY_INITIAL_BALANCE`, `DAPP_INITIAL_BALANCE`, or `DAPP_TEST_INITIAL_BALANCE`

The balance, in wei, given to each test contract and to the accounts that deploy and call
it.

Forge sets it on the test contract before deployment, so it is available in the
constructor, and then resets the test `sender` and Forge's internal caller and library
deployer accounts to it. Write it as a decimal or hexadecimal string, such as
`"0xffffffffffffffffffffffff"`; TOML integers are rejected. The `--initial-balance` flag
overrides it.

#### `block_number`

* Type: integer or string
* Default: `1`
* Environment: `FOUNDRY_BLOCK_NUMBER`, `DAPP_BLOCK_NUMBER`, `DAPP_TEST_BLOCK_NUMBER`, or `DAPP_TEST_NUMBER`

The `block.number` value during local EVM execution.

When forking, the fork block's number is used instead. The `--block-number` flag overrides
it.

#### `chain_id`

* Type: string or integer (chain name or ID)
* Default: none
* Environment: `FOUNDRY_CHAIN_ID`, `DAPP_CHAIN_ID`, `DAPP_TEST_CHAIN_ID`, or `FOUNDRY_CHAIN`
* Aliases: `chain`

The chain Foundry targets, as a chain name or EIP-155 chain ID.

Accepts a name such as `"mainnet"` or `"sepolia"`, or a number such as `1`. It sets the
`chainid` value during EVM execution: when unset, local execution uses 31337 and forks use
the chain ID reported by the RPC, and when set it overrides the fork's chain ID. Commands
also use it to choose the block explorer settings and API key from `[etherscan]`, and
`cast` commands use it as the transaction chain. The `--chain` (`--chain-id`) flag
overrides it.

```toml
[profile.default]
chain_id = "sepolia"
```

#### `network`

* Type: string
* Default: none
* Environment: `FOUNDRY_NETWORK`, `DAPP_NETWORK`, or `DAPP_TEST_NETWORK`
* Values: `ethereum`, `base` (requires the `base` build feature), `optimism` (requires the `optimism` build feature), `tempo`, `monad` (requires the `monad` build feature)

Enable a specific network family.

The values exposed by a binary depend on its compiled features. Use this setting
when Foundry is not forking a recognized live RPC endpoint and therefore cannot
infer the execution family. Foundry still accepts the legacy boolean forms such
as `optimism = true`, `tempo = true`, and `monad = true` when the corresponding
family is available. See [Network configuration](/config/networks) for runtime
selection, fork inference, and build availability.

```toml
[profile.default]
network = "tempo"
```

#### `hardfork`

* Type: string
* Default: none
* Environment: `FOUNDRY_HARDFORK`, `DAPP_HARDFORK`, or `DAPP_TEST_HARDFORK`

The EVM hardfork used to execute tests, scripts and other local EVM runs.

Accepts a plain Ethereum hardfork name, such as `osaka` or `cancun`, or a hardfork
namespaced by network, such as `optimism:holocene`, `base:Beryl` or `tempo:T6`. The
namespaces are `ethereum` (`eth`), `optimism` (`op`), `base`, `tempo` (`t`) and `monad`
(`m`); the non-Ethereum namespaces other than `tempo` are only available in builds compiled
with the matching network feature.

A namespaced hardfork also selects the matching network. A hardfork that conflicts with an
explicitly configured network, such as `hardfork = "shanghai"` with `network = "tempo"`, is
rejected.

When unset, execution follows `evm_version`, or the forked endpoint's own hardfork when
forking. This setting only changes execution: contracts are still compiled for
`evm_version`. The `--hardfork` flag overrides it.

```toml
[profile.default]
hardfork = "tempo:T6"
```

For Tempo projects, prefer `network = "tempo"` or a live Tempo fork for current behavior,
and pin a Tempo hardfork only when you need deterministic behavior at a specific activation
point.

#### `gas_limit`

* Type: integer, numeric string, or "max"
* Default: `1073741824`
* Environment: `FOUNDRY_GAS_LIMIT`, `DAPP_GAS_LIMIT`, or `DAPP_TEST_GAS_LIMIT`

The gas limit for each top-level call in tests and scripts, also used as `block.gaslimit`.

Forge gives every top-level call this much gas and sets `block.gaslimit` to the same value.
When `block_gas_limit` is set, it replaces this value for both. Accepts an integer, a
numeric string, or `"max"` for the largest 64-bit value. TOML integers are signed 64-bit,
so write larger values as a string:

```toml
[profile.default]
gas_limit = "max"
```

The CLI flag `--gas-limit` is an alias of `--block-gas-limit` and sets `block_gas_limit`,
not this key.

#### `gas_price`

* Type: integer
* Default: none
* Environment: `FOUNDRY_GAS_PRICE`, `DAPP_GAS_PRICE`, or `DAPP_TEST_GAS_PRICE`

The `tx.gasprice` value, in wei, during EVM execution.

When unset, local execution uses 0 and forks use the RPC's current gas price. This only
affects simulated execution; the price of broadcast transactions is set by fee estimation
and flags such as `--with-gas-price`. The `--gas-price` flag overrides it.

#### `block_base_fee_per_gas`

* Type: integer
* Default: `0`
* Environment: `FOUNDRY_BLOCK_BASE_FEE_PER_GAS`, `DAPP_BLOCK_BASE_FEE_PER_GAS`, or `DAPP_TEST_BLOCK_BASE_FEE_PER_GAS`

The `block.basefee` value, in wei, during local EVM execution.

When forking, the fork block's base fee is used instead. The `--block-base-fee-per-gas`
(`--base-fee`) flag overrides it.

#### `block_coinbase`

* Type: string (address)
* Default: `"0x0000000000000000000000000000000000000000"`
* Environment: `FOUNDRY_BLOCK_COINBASE`, `DAPP_BLOCK_COINBASE`, or `DAPP_TEST_BLOCK_COINBASE`

The `block.coinbase` value during local EVM execution.

When forking, the fork block's beneficiary is used instead. The `--block-coinbase` flag
overrides it.

#### `block_timestamp`

* Type: integer or string
* Default: `1`
* Environment: `FOUNDRY_BLOCK_TIMESTAMP`, `DAPP_BLOCK_TIMESTAMP`, `DAPP_TEST_BLOCK_TIMESTAMP`, or `DAPP_TEST_TIMESTAMP`

The `block.timestamp` value, in seconds, during local EVM execution.

When forking, the fork block's timestamp is used instead. The `--block-timestamp` flag
overrides it.

#### `block_difficulty`

* Type: integer
* Default: `0`
* Environment: `FOUNDRY_BLOCK_DIFFICULTY`, `DAPP_BLOCK_DIFFICULTY`, or `DAPP_TEST_BLOCK_DIFFICULTY`

The `block.difficulty` value during local EVM execution.

Since the Merge (Paris), the `DIFFICULTY` opcode returns `block.prevrandao` instead, so
this value only applies to pre-Paris EVM versions; set `block_prevrandao` otherwise. When
forking, the fork block's difficulty is used instead. The `--block-difficulty` flag
overrides it.

#### `gas_reports`

* Type: array of string
* Default: `["*"]`
* Environment: `FOUNDRY_GAS_REPORTS`, `DAPP_GAS_REPORTS`, or `DAPP_TEST_GAS_REPORTS`

The contracts to include in gas reports generated by `forge test --gas-report`.

Entries are exact contract names, without the source path. `"*"`, or an empty list, reports
every contract. A contract listed here is reported even if it also appears in
`gas_reports_ignore`, and Forge prints a warning about the double listing.

```toml
[profile.default]
gas_reports = ["Counter", "Token"]
```

#### `no_storage_caching`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_NO_STORAGE_CACHING`, `DAPP_NO_STORAGE_CACHING`, or `DAPP_TEST_NO_STORAGE_CACHING`

Whether to disable on-disk caching of fork state entirely.

When enabled, every account and storage slot is fetched from the endpoint and nothing is
read from or written to `~/.foundry/cache/rpc`, overriding `rpc_storage_caching`. This also
applies to forks created by cheatcodes, and stops `fork_prefetch` from warming a new fork
block from an older cache. The `--no-storage-caching` flag enables it for a single run.

#### `fork_prefetch`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_FORK_PREFETCH`, `DAPP_FORK_PREFETCH`, or `DAPP_TEST_FORK_PREFETCH`

Whether to prefetch remote fork state before the EVM reads it.

Prefetching works in two ways:

* Each call into a contract on the fork is simulated on the endpoint with
  `eth_createAccessList` while the EVM runs it. Foundry then fetches the storage slots in
  the result in parallel batch requests, and the accounts in parallel separate requests. A
  top-level call, such as a test function, sends the state that exists only locally, such
  as the test contract and balances set with cheatcodes, as state overrides. A cold call
  then costs a few round trips instead of one per slot. A call is simulated again on each
  run until its access list holds at most two new keys or reads mostly hit the cache. An
  endpoint without `eth_createAccessList` turns the simulations off, and one that rejects
  state overrides turns them off for top-level calls. The first failed or slow (over 3
  seconds) batch request, for example from a rate limit, stops prefetching on that fork.
* A fork of the latest block whose storage cache is empty is warmed in the background with
  the accounts and slots cached for the newest older block on the same chain, read again at
  the new block. Such forks start cold on each new head, for example in CI, so this saves
  the first reads. It needs storage caching, so it does not run with `no_storage_caching`,
  for endpoints or chains that `rpc_storage_caching` excludes, with a pinned
  `fork_block_number`, or with `fork_state_by_number`.

Results do not change, because every value comes from the fork block. Keys the run does not
read cost extra RPC requests, and the simulations and batch requests count against the
endpoint's rate limit. The `--fork-prefetch` flag enables it for a single run.

```toml
[profile.ci]
fork_prefetch = true
```

#### `[rpc_storage_caching]`

Which chains and RPC endpoints have their fork state cached on disk.

Fork data (accounts, storage and block data) is cached per chain and block under
`~/.foundry/cache/rpc/<chain>/<block>/`, so later runs of the same fork block reuse it
instead of fetching it again. A fork is cached only if both `chains` and `endpoints` match
it. Local development chains (chain IDs 99, 1337 and 31337) are never cached.
`no_storage_caching` disables caching regardless of this table, and `forge cache clean`
removes the cache.

```toml
[profile.default.rpc_storage_caching]
chains = ["mainnet", "optimism"]
endpoints = "remote"
```

##### `rpc_storage_caching.chains`

* Type: "all", "none", or array of chain names or IDs
* Default: `"all"`

Chains whose fork state is cached.

Valid values:

* `"all"`: cache every chain.
* `"none"`: cache no chain.
* An array of chain names or EIP-155 IDs, such as `["mainnet", "optimism"]` or `[1, 10]`.

Local development chains (chain IDs 99, 1337 and 31337) are never cached.

##### `rpc_storage_caching.endpoints`

* Type: "all", "remote", or string (regular expression)
* Default: `"all"`

RPC endpoints whose fork state is cached.

Valid values:

* `"all"`: cache every endpoint.
* `"remote"`: cache endpoints whose URL contains neither `localhost:` nor `127.0.0.1:`.
* Any other string: a regular expression; endpoints whose URL matches it are cached.

#### `eth_rpc_url`

* Type: string
* Default: none
* Environment: `FOUNDRY_ETH_RPC_URL`, `DAPP_ETH_RPC_URL`, or `DAPP_TEST_ETH_RPC_URL`

URL or alias of the RPC endpoint used for RPC calls and for the main fork in tests and
scripts.

Accepts an HTTP(S) or WebSocket URL, an IPC socket path, or an alias. An alias is resolved
in this order: a key of `rpc_endpoints`, an endpoint known to MESC (queried under the
`foundry` profile), then the built-in `tempo` and `moderato` aliases. Any other value is
used as-is. `${VAR}` placeholders are only expanded through an `rpc_endpoints` alias, not
in a URL written here directly.

When set, `forge test` and `forge script` run against a fork of this endpoint, pinned to
`fork_block_number` or to the latest block. Commands such as `cast` that need an endpoint
fall back to `http://localhost:8545` when it is unset. The value also selects the
`etherscan` entry of the same name when `etherscan_api_key` names none.

The `--rpc-url` (`--fork-url`) flag overrides it. `cast` also reads the `ETH_RPC_URL`
environment variable; `forge` does not, so exporting it does not fork every test run.

```toml
[profile.default]
eth_rpc_url = "mainnet"

[rpc_endpoints]
mainnet = "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}"
```

#### `etherscan_api_key`

* Type: string
* Default: none
* Environment: `DAPP_ETHERSCAN_API_KEY`, `DAPP_TEST_ETHERSCAN_API_KEY`, or `ETHERSCAN_API_KEY`

Etherscan API key, or the name of an entry in the `etherscan` table.

If the value names an `etherscan` entry, that entry is used. Otherwise Foundry uses the
first `etherscan` entry whose chain matches the current chain, with this value replacing
the entry's key, and with no matching entry it builds a config for the current chain from
this key and the chain's known explorer URL. With Etherscan API V2, one Etherscan key works
for every chain that Etherscan serves (such as BscScan, BaseScan or Polygonscan).

The key is used for contract verification, fetching verified sources and identifying
contracts in traces. The `--etherscan-api-key` flag and the `ETHERSCAN_API_KEY` environment
variable (ignored when empty) override it. Avoid committing the key; prefer the environment
or an `etherscan` entry with a `${VAR}` placeholder.

<span id="match-test" />

#### `match_test`

* Type: string (regular expression)
* Default: none
* Environment: `FOUNDRY_MATCH_TEST`, `DAPP_MATCH_TEST`, or `DAPP_TEST_MATCH_TEST`

Only run test functions whose signature matches this regular expression.

The pattern is searched for anywhere in the full function signature, such as
`test_transfer(uint256)`; anchor it with `^` and `$` to match exactly. It applies to
`forge test` and to the commands built on it, such as `forge coverage` and
`forge snapshot`. The `--match-test` (`--mt`) flag replaces this value.

```toml
[profile.default]
match_test = "^test_transfer"
```

<span id="no-match-test" />

#### `no_match_test`

* Type: string (regular expression)
* Default: none
* Environment: `FOUNDRY_NO_MATCH_TEST`, `DAPP_NO_MATCH_TEST`, or `DAPP_TEST_NO_MATCH_TEST`

Skip test functions whose signature matches this regular expression.

The pattern is searched for anywhere in the full function signature, such as
`test_transfer(uint256)`. It applies to `forge test` and to the commands built on it, such
as `forge coverage` and `forge snapshot`. The `--no-match-test` (`--nmt`) flag replaces
this value.

<span id="match-contract" />

#### `match_contract`

* Type: string (regular expression)
* Default: none
* Environment: `FOUNDRY_MATCH_CONTRACT`, `DAPP_MATCH_CONTRACT`, or `DAPP_TEST_MATCH_CONTRACT`

Only run tests in contracts whose name matches this regular expression.

The pattern is searched for anywhere in the contract name; anchor it with `^` and `$` to
match exactly. It applies to `forge test` and to the commands built on it, such as
`forge coverage` and `forge snapshot`. The `--match-contract` (`--mc`) flag replaces this
value.

<span id="no-match-contract" />

#### `no_match_contract`

* Type: string (regular expression)
* Default: none
* Environment: `FOUNDRY_NO_MATCH_CONTRACT`, `DAPP_NO_MATCH_CONTRACT`, or `DAPP_TEST_NO_MATCH_CONTRACT`

Skip tests in contracts whose name matches this regular expression.

The pattern is searched for anywhere in the contract name. It applies to `forge test` and
to the commands built on it, such as `forge coverage` and `forge snapshot`. The
`--no-match-contract` (`--nmc`) flag replaces this value.

<span id="match-path" />

#### `match_path`

* Type: string (glob)
* Default: none
* Environment: `FOUNDRY_MATCH_PATH`, `DAPP_MATCH_PATH`, or `DAPP_TEST_MATCH_PATH`

Only run tests in source files whose path matches this glob pattern.

Paths are matched relative to the project root, such as `test/unit/Counter.t.sol`. A file
also matches when its file name contains the pattern text. It applies to `forge test` and
to the commands built on it, such as `forge coverage` and `forge snapshot`. The
`--match-path` (`--mp`) flag replaces this value.

```toml
[profile.default]
match_path = "test/unit/*"
```

<span id="no-match-path" />

#### `no_match_path`

* Type: string (glob)
* Default: none
* Environment: `FOUNDRY_NO_MATCH_PATH`, `DAPP_NO_MATCH_PATH`, or `DAPP_TEST_NO_MATCH_PATH`

Skip tests in source files whose path matches this glob pattern.

Paths are matched relative to the project root, such as `test/fork/Counter.t.sol`. A file
also matches when its file name contains the pattern text. It applies to `forge test` and
to the commands built on it, such as `forge coverage` and `forge snapshot`. The
`--no-match-path` (`--nmp`) flag replaces this value.

#### `threads`

* Type: integer
* Default: none
* Environment: `FOUNDRY_THREADS`, `DAPP_THREADS`, or `DAPP_TEST_THREADS`

Number of threads for parallel work such as running tests; `0` uses all logical cores.

**Note:** Forge currently sizes its thread pool only from the global `--threads` (`-j`,
`--jobs`) flag, so this setting has no effect.

#### `show_progress`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_SHOW_PROGRESS`, `DAPP_SHOW_PROGRESS`, or `DAPP_TEST_SHOW_PROGRESS`

Whether `forge test` shows live progress for the run and each test suite while tests
execute.

The `--show-progress` flag enables it for one run.

#### `block_gas_limit`

* Type: integer, numeric string, or "max"
* Default: none
* Environment: `FOUNDRY_BLOCK_GAS_LIMIT`, `DAPP_BLOCK_GAS_LIMIT`, or `DAPP_TEST_BLOCK_GAS_LIMIT`

The `block.gaslimit` value and per-call gas limit, overriding `gas_limit` when set.

When unset, `gas_limit` is used for both. Accepts an integer, a numeric string, or `"max"`.
The `--block-gas-limit` flag, also spelled `--gas-limit`, overrides it.

#### `memory_limit`

* Type: integer
* Default: `134217728`
* Environment: `FOUNDRY_MEMORY_LIMIT`, `DAPP_MEMORY_LIMIT`, or `DAPP_TEST_MEMORY_LIMIT`

The maximum memory, in bytes, that a single EVM execution may use.

An execution that exceeds it halts with a `MemoryLimitOOG` error. The `--memory-limit` flag
overrides it.

#### `names`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_NAMES`, `DAPP_NAMES`, or `DAPP_TEST_NAMES`

Whether `forge build` prints the names of the compiled contracts, grouped by compiler
version.

**Note:** `forge build` currently reads only its `--names` flag, so this setting has no
effect.

#### `sizes`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_SIZES`, `DAPP_SIZES`, or `DAPP_TEST_SIZES`

Whether `forge build` prints the runtime and initcode sizes of the compiled contracts.

With `--sizes`, the build also fails when a contract exceeds the runtime size limit
(EIP-170, or `code_size_limit`) or the initcode size limit (EIP-3860, unless
`--ignore-eip-3860` is passed).

**Note:** `forge build` currently reads only its `--sizes` flag, so this setting has no
effect.

#### `[rpc_endpoints]`

* Type: table
* Default: `{}`

Named RPC endpoints that can be referenced by alias.

Aliases work in `eth_rpc_url`, in `--rpc-url`/`--fork-url`, and in cheatcodes such as
`vm.createFork`, `vm.createSelectFork`, `vm.rpcUrl` and `vm.rpcUrls`. The table can be
written at the top level as `[rpc_endpoints]` or inside a profile.

Each value is either a URL string or a table with:

* `endpoint` (alias `url`): the endpoint URL.
* `endpoints`: an array of URLs, instead of `endpoint`. `anvil --fork-url <alias>`
  load-balances across all of them with failover; other users take the first.
* `auth`: a value sent as the `Authorization` header, such as `"Bearer <token>"`, to forks
  created by cheatcodes and to `chisel` forks.
* `retries`: number of retries for forks created by cheatcodes, overriding
  `--fork-retries`.
* `retry_backoff`: initial retry backoff in milliseconds for forks created by cheatcodes,
  overriding `--fork-retry-backoff`.
* `compute_units_per_second`: assumed compute units per second for forks created by
  cheatcodes, used only when the run sets none.

Exactly one of `endpoint` and `endpoints` is required. URLs and `auth` may contain `${VAR}`
placeholders, which are resolved from the environment when the endpoint is used, so an
unset variable only fails where that endpoint is needed.

```toml
[rpc_endpoints]
optimism = "https://optimism.example.com/v2/${API_KEY}"
mainnet = "${RPC_MAINNET}"
fallback = { endpoints = ["${MAINNET_RPC_URL}", "${FALLBACK_RPC_URL}"], retries = 5 }
private = { endpoint = "https://rpc.example.com", auth = "Bearer ${RPC_TOKEN}" }
```

#### `prompt_timeout`

* Type: integer
* Default: `120`
* Environment: `FOUNDRY_PROMPT_TIMEOUT`, `DAPP_PROMPT_TIMEOUT`, or `DAPP_TEST_PROMPT_TIMEOUT`

How many seconds `vm.prompt` and the related prompt cheatcodes wait for input before
reverting.

The timeout keeps unattended runs, such as CI, from hanging on a prompt.

### Fuzz

Configuration values for `[fuzz]` section. Coverage-guided fields are documented in
[Advanced Testing](/config/reference/advanced-testing#additional-fuzz-and-invariant-fields).

#### `[fuzz]`

Settings for fuzz tests, which run test functions that take parameters with generated
inputs.

Declare them in a `[profile.<name>.fuzz]` table, or in a standalone `[fuzz]` table that
applies to every profile; a profile's own table takes precedence. Individual tests can
override them with inline `forge-config` comments. The `invariant` section falls back to
these values for the settings both sections share.

#### `runs`

* Type: integer
* Default: `256`
* Environment: `FOUNDRY_FUZZ_RUNS` or `DAPP_TEST_FUZZ_RUNS`

Number of fuzz runs (generated inputs) to execute for each fuzz test.

Higher values give more confidence in the results at the cost of testing speed. Must be
greater than 0. With `timeout` set, the campaign stops at whichever comes first.

#### `fail_on_revert`

* Type: boolean
* Default: `true`
* Environment: `FOUNDRY_FUZZ_FAIL_ON_REVERT`

Whether a fuzz case fails when the test call reverts.

When `true`, any revert fails the test. When `false`, a case whose revert originated in a
contract other than the test contract is treated as passing; reverts raised by the test
contract itself or by cheatcodes, such as failed assertions, still fail it.

#### `max_test_rejects`

* Type: integer
* Default: `65536`
* Environment: `FOUNDRY_FUZZ_MAX_TEST_REJECTS`

Maximum number of inputs rejected with `vm.assume` before the whole fuzz test fails.

Rejections are counted across all runs of the test: a rejected input is discarded and a new
one is generated. If a test hits this limit, narrow its inputs with `bound` instead of
rejecting them, or raise the limit.

#### `seed`

* Type: string (decimal or hex integer)
* Default: none
* Environment: `FOUNDRY_FUZZ_SEED`

Seed for the fuzzer's random number generator, which makes fuzz and invariant campaigns
reproducible.

Write it as a decimal or hexadecimal string, such as `"0x1234"`; TOML integers are
rejected. Each worker derives its own random stream from the seed; worker `0` uses it
unchanged. In fuzz tests the seed also drives cheatcode randomness, such as
`vm.randomUint`. Invariant tests read this value too: there is no `invariant.seed`. When
unset, every campaign uses a fresh random seed.

#### `dictionary_weight`

* Type: integer or numeric string
* Default: `40`
* Environment: `FOUNDRY_FUZZ_DICTIONARY_WEIGHT`

Percentage (0 to 100) of fuzzed values drawn from the fuzz dictionary instead of generated
at random.

The dictionary holds values collected from the project and its execution, such as literals
in the source code, values in storage, constants pushed by contract bytecode and addresses
of deployed contracts. A higher weight biases inputs towards these "interesting" values; a
lower weight favors random ones. Invariant campaigns also use it to pick senders and block
delays.

#### `include_storage`

* Type: boolean
* Default: `true`
* Environment: `FOUNDRY_FUZZ_INCLUDE_STORAGE`

Whether to add the storage values of contracts touched during execution to the fuzz
dictionary.

#### `include_push_bytes`

* Type: boolean
* Default: `true`
* Environment: `FOUNDRY_FUZZ_INCLUDE_PUSH_BYTES`

Whether to add the constants pushed by contract bytecode (`PUSH` operands) and the
contracts' addresses to the fuzz dictionary.

#### `include_view_values`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_FUZZ_INCLUDE_VIEW_VALUES`

Whether invariant campaigns add the results of targeted contracts' view functions to the
fuzz dictionary.

After each successful call, view functions with no inputs or only address inputs are called
on the targeted contracts that the call accessed, with address inputs set to the call's
sender, and their results, whole structs included, are added to the dictionary. This lets
later calls pass back values that only exist in storage, such as a struct read from a
getter. At most 32 views are called after each call; when more are eligible, the selection
rotates across calls so every view is reached.

Only affects invariant tests; like the other shared keys, a value set under `[fuzz]` also
applies to `[invariant]` unless `[invariant]` sets its own.

#### `max_fuzz_dictionary_addresses`

* Type: integer, numeric string, or "max"
* Default: `15728640`
* Environment: `FOUNDRY_FUZZ_MAX_FUZZ_DICTIONARY_ADDRESSES`

Maximum number of addresses kept in the fuzz dictionary.

Once the limit is exceeded, the fuzzer starts evicting random entries. The limit prevents
memory blowup. Set it to `"max"` for no limit.

#### `max_fuzz_dictionary_values`

* Type: integer, numeric string, or "max"
* Default: `9830400`
* Environment: `FOUNDRY_FUZZ_MAX_FUZZ_DICTIONARY_VALUES`

Maximum number of values kept in the fuzz dictionary.

Once the limit is exceeded, the fuzzer starts evicting random entries. The dictionary
always keeps a zero value, so the effective minimum is one. Set it to `"max"` for no limit.

#### `max_fuzz_dictionary_literals`

* Type: integer, numeric string, or "max"
* Default: `6553600`
* Environment: `FOUNDRY_FUZZ_MAX_FUZZ_DICTIONARY_LITERALS`

Maximum number of literal values from the source code (AST) seeded into the fuzz
dictionary.

This limit is independent of `max_fuzz_dictionary_addresses` and
`max_fuzz_dictionary_values`. Set it to `"max"` for no limit.

#### `gas_report_samples`

* Type: integer
* Default: `256`
* Environment: `FOUNDRY_FUZZ_GAS_REPORT_SAMPLES`

Number of fuzz runs whose traces are kept for the gas report.

At least one run is always kept, so its trace can be displayed.

#### `corpus_dir`

* Type: string (path)
* Default: none
* Environment: `FOUNDRY_FUZZ_CORPUS_DIR`

Directory for the corpus; setting it enables coverage-guided fuzzing.

In coverage-guided mode, inputs (call sequences, for invariant tests) that reach new edge
coverage are kept in a corpus, persisted in this directory per contract and test, and
mutated to generate new inputs, and edge coverage metrics are displayed. When unset, inputs
that produce new coverage are neither persisted nor mutated. `forge clean` removes the
directory.

#### `corpus_gzip`

* Type: boolean
* Default: `true`
* Environment: `FOUNDRY_FUZZ_CORPUS_GZIP`

Whether corpus entries are written with gzip compression.

Only entries above a small size threshold are compressed. When `false`, every entry is
written as a plain JSON file. Only relevant when `corpus_dir` is set.

#### `corpus_min_mutations`

* Type: integer
* Default: `5`
* Environment: `FOUNDRY_FUZZ_CORPUS_MIN_MUTATIONS`

Number of times a corpus entry must be mutated before it may be evicted from memory.

Only entries mutated more than this many times that are not favored can be evicted from the
in-memory corpus. Only relevant when `corpus_dir` is set.

#### `corpus_min_size`

* Type: integer
* Default: `0`
* Environment: `FOUNDRY_FUZZ_CORPUS_MIN_SIZE`

Number of corpus entries kept in memory without eviction.

Entries are evicted only while the in-memory corpus holds more than this many entries, and
always at least one is kept. Only relevant when `corpus_dir` is set.

#### `show_edge_coverage`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_FUZZ_SHOW_EDGE_COVERAGE`

Whether to collect and display edge coverage metrics.

Edge coverage is always collected when `corpus_dir` is set; enable this to see it without
coverage-guided fuzzing.

#### `instrumented_edges`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_FUZZ_INSTRUMENTED_EDGES`

Whether EVM edge coverage comes from compiler instrumentation instead of the `JUMP`/`JUMPI`
edge inspector.

Coverage builds of a compiler emit `PUSHn <id>; EDGECOV` (opcode `0xC0`) on every
control-flow edge, with dense IDs starting at 1. When enabled, the EVM executes that
opcode, which records a hit for the edge and costs no gas (it also refunds its `PUSH`), and
these hits replace the inspector's EVM edges as the corpus guidance signal. Comparison
operands then come from the compiler's `CMPLOG` (`0xC1`) probes instead of the cmp-log
inspector. Instrumented artifacts only run with this on: on any other EVM `0xC0` and `0xC1`
are undefined opcodes.

Hits are keyed by ID alone, so IDs must be unique across all instrumented code: build it in
one compiler invocation.

#### `failure_persist_dir`

* Type: string (path)
* Default: `"cache/fuzz"`
* Environment: `FOUNDRY_FUZZ_FAILURE_PERSIST_DIR`

Directory where fuzz failures are recorded and replayed.

When a fuzz test fails, its counterexample is saved under `failures/<contract>/<test>` in
this directory and replayed first the next time the test runs, so the test keeps failing
until the bug is fixed. `forge clean` removes the directory.

#### `show_logs`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_FUZZ_SHOW_LOGS`

Whether to show the `console.log` output of every fuzz run instead of only the last one.

Logs are displayed only at verbosity 2 or higher: run `forge test -vv` or set `verbosity`
to at least 2. Without this setting, only the logs of the last run, or of the failing case,
are shown.

#### `timeout`

* Type: integer
* Default: none
* Environment: `FOUNDRY_FUZZ_TIMEOUT`

Time limit, in seconds, for each fuzz test campaign.

The campaign stops at the timeout or after `runs` runs, whichever comes first; stopping at
the timeout does not fail the test. When unset, there is no time limit.

### Invariant

Configuration values for `[invariant]` section.

> ℹ️ **Note**
>
> Configuration for `[invariant]` section has the fallback logic
> for common config entries (`runs`, `seed`, `dictionary_weight` etc).
>
> * If the entries are not set in either section, then the defaults will be used.
> * If the entries are set in the `[fuzz]` section, but are not set in the `[invariant]`
>   section, these values will automatically be set to the values specified in
>   the `[fuzz]` section.
> * For any profile other than `default`:
>   * If at least one entry is set in the `[invariant]` (same as
>     `[profile.default.invariant]`) section, then the values from
>     `[invariant]` section will be used, including defaults.
>   * If no entry is set in the `[invariant]` section, but there are
>     entries in the `[fuzz]` (same as `[profile.default.fuzz]`) section,
>     then the values from the `[fuzz]` section will be used.
>   * If it's none of the cases described above, then the defaults
>     will be used.

#### `[invariant]`

Settings for invariant tests, which check `invariant_*` functions after random call
sequences.

Declare them in a `[profile.<name>.invariant]` table, or in a standalone `[invariant]`
table that applies to every profile; a profile's own table takes precedence. Individual
tests can override them with inline `forge-config` comments.

Any key set in the standalone `[fuzz]` table that the standalone `[invariant]` table
doesn't set also applies to invariant tests, such as `runs`, `dictionary_weight`, the
`include_*` keys and the `corpus_*` keys. Invariant tests have no seed of their own:
they use `fuzz.seed`.

#### `runs`

* Type: integer
* Default: `256`
* Environment: `FOUNDRY_INVARIANT_RUNS`

Number of runs to execute for each invariant test group.

Each run starts from the state after `setUp` and executes a sequence of up to `depth`
calls, checking the invariants as it goes. With `timeout` set, the campaign runs until the
timeout instead. See also `fuzz.runs`.

#### `depth`

* Type: integer
* Default: `500`
* Environment: `FOUNDRY_INVARIANT_DEPTH` or `DAPP_TEST_DEPTH`

Number of calls executed in one run to try to break the invariants.

With `depth_mode = "random"`, this is the maximum depth of a run.

#### `fail_on_revert`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_INVARIANT_FAIL_ON_REVERT`

Whether a reverting handler call fails the invariant test.

When `true`, the run stops at the first call that reverts and the test fails with that call
sequence as its counterexample. When `false`, reverting calls are counted in the metrics
and the run continues.

#### `call_override`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_INVARIANT_CALL_OVERRIDE`

Whether to inject reentrant calls into targeted contracts during invariant runs, to test
for reentrancy.

When enabled, external calls to a targeted (handler) contract can be overridden with a
fuzzed call to one of the targets' functions, simulating a malicious contract that reenters
when it receives a call, such as through its `receive` function. Branch frontier capture
(`frontier_dir`) does not support it: such campaigns run without writing frontier
artifacts, with a warning.

#### `dictionary_weight`

* Type: integer or numeric string
* Default: `80`
* Environment: `FOUNDRY_INVARIANT_DICTIONARY_WEIGHT`

Percentage (0 to 100) of fuzzed values drawn from the fuzz dictionary instead of generated
at random.

The dictionary holds values collected from the project and its execution, such as literals
in the source code, values in storage, constants pushed by contract bytecode and addresses
of deployed contracts. A higher weight biases inputs towards these "interesting" values; a
lower weight favors random ones. Invariant campaigns also use it to pick senders and block
delays.

#### `include_storage`

* Type: boolean
* Default: `true`
* Environment: `FOUNDRY_INVARIANT_INCLUDE_STORAGE`

Whether to add the storage values of contracts touched during execution to the fuzz
dictionary.

#### `include_push_bytes`

* Type: boolean
* Default: `true`
* Environment: `FOUNDRY_INVARIANT_INCLUDE_PUSH_BYTES`

Whether to add the constants pushed by contract bytecode (`PUSH` operands) and the
contracts' addresses to the fuzz dictionary.

#### `include_view_values`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_INVARIANT_INCLUDE_VIEW_VALUES`

Whether invariant campaigns add the results of targeted contracts' view functions to the
fuzz dictionary.

After each successful call, view functions with no inputs or only address inputs are called
on the targeted contracts that the call accessed, with address inputs set to the call's
sender, and their results, whole structs included, are added to the dictionary. This lets
later calls pass back values that only exist in storage, such as a struct read from a
getter. At most 32 views are called after each call; when more are eligible, the selection
rotates across calls so every view is reached.

Only affects invariant tests; like the other shared keys, a value set under `[fuzz]` also
applies to `[invariant]` unless `[invariant]` sets its own.

#### `max_fuzz_dictionary_addresses`

* Type: integer, numeric string, or "max"
* Default: `15728640`
* Environment: `FOUNDRY_INVARIANT_MAX_FUZZ_DICTIONARY_ADDRESSES`

Maximum number of addresses kept in the fuzz dictionary.

Once the limit is exceeded, the fuzzer starts evicting random entries. The limit prevents
memory blowup. Set it to `"max"` for no limit.

#### `max_fuzz_dictionary_values`

* Type: integer, numeric string, or "max"
* Default: `9830400`
* Environment: `FOUNDRY_INVARIANT_MAX_FUZZ_DICTIONARY_VALUES`

Maximum number of values kept in the fuzz dictionary.

Once the limit is exceeded, the fuzzer starts evicting random entries. The dictionary
always keeps a zero value, so the effective minimum is one. Set it to `"max"` for no limit.

#### `max_fuzz_dictionary_literals`

* Type: integer, numeric string, or "max"
* Default: `6553600`
* Environment: `FOUNDRY_INVARIANT_MAX_FUZZ_DICTIONARY_LITERALS`

Maximum number of literal values from the source code (AST) seeded into the fuzz
dictionary.

This limit is independent of `max_fuzz_dictionary_addresses` and
`max_fuzz_dictionary_values`. Set it to `"max"` for no limit.

#### `shrink_run_limit`

* Type: integer
* Default: `5000`
* Environment: `FOUNDRY_INVARIANT_SHRINK_RUN_LIMIT`

Maximum number of attempts to shrink a failing call sequence.

Shrinking removes and simplifies calls to find the shortest sequence that still fails. `0`
disables shrinking. The same limit bounds minimizing the argument values of stateless fuzz
test counterexamples, so set it under `[invariant]` for fuzz tests too.

#### `max_assume_rejects`

* Type: integer
* Default: `65536`
* Environment: `FOUNDRY_INVARIANT_MAX_ASSUME_REJECTS`

Maximum number of `vm.assume` rejections allowed in a single invariant run before the test
fails.

#### `gas_report_samples`

* Type: integer
* Default: `256`
* Environment: `FOUNDRY_INVARIANT_GAS_REPORT_SAMPLES`

Number of invariant runs whose traces are kept for the gas report.

The samples are split across the campaign's workers.

#### `corpus_dir`

* Type: string (path)
* Default: none
* Environment: `FOUNDRY_INVARIANT_CORPUS_DIR`

Directory for the corpus; setting it enables coverage-guided fuzzing.

In coverage-guided mode, inputs (call sequences, for invariant tests) that reach new edge
coverage are kept in a corpus, persisted in this directory per contract and test, and
mutated to generate new inputs, and edge coverage metrics are displayed. When unset, inputs
that produce new coverage are neither persisted nor mutated. `forge clean` removes the
directory.

#### `corpus_gzip`

* Type: boolean
* Default: `true`
* Environment: `FOUNDRY_INVARIANT_CORPUS_GZIP`

Whether corpus entries are written with gzip compression.

Only entries above a small size threshold are compressed. When `false`, every entry is
written as a plain JSON file. Only relevant when `corpus_dir` is set.

#### `corpus_min_mutations`

* Type: integer
* Default: `5`
* Environment: `FOUNDRY_INVARIANT_CORPUS_MIN_MUTATIONS`

Number of times a corpus entry must be mutated before it may be evicted from memory.

Only entries mutated more than this many times that are not favored can be evicted from the
in-memory corpus. Only relevant when `corpus_dir` is set.

#### `corpus_min_size`

* Type: integer
* Default: `0`
* Environment: `FOUNDRY_INVARIANT_CORPUS_MIN_SIZE`

Number of corpus entries kept in memory without eviction.

Entries are evicted only while the in-memory corpus holds more than this many entries, and
always at least one is kept. Only relevant when `corpus_dir` is set.

#### `show_edge_coverage`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_INVARIANT_SHOW_EDGE_COVERAGE`

Whether to collect and display edge coverage metrics.

Edge coverage is always collected when `corpus_dir` is set; enable this to see it without
coverage-guided fuzzing.

#### `instrumented_edges`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_INVARIANT_INSTRUMENTED_EDGES`

Whether EVM edge coverage comes from compiler instrumentation instead of the `JUMP`/`JUMPI`
edge inspector.

Coverage builds of a compiler emit `PUSHn <id>; EDGECOV` (opcode `0xC0`) on every
control-flow edge, with dense IDs starting at 1. When enabled, the EVM executes that
opcode, which records a hit for the edge and costs no gas (it also refunds its `PUSH`), and
these hits replace the inspector's EVM edges as the corpus guidance signal. Comparison
operands then come from the compiler's `CMPLOG` (`0xC1`) probes instead of the cmp-log
inspector. Instrumented artifacts only run with this on: on any other EVM `0xC0` and `0xC1`
are undefined opcodes.

Hits are keyed by ID alone, so IDs must be unique across all instrumented code: build it in
one compiler invocation.

#### `failure_persist_dir`

* Type: string (path)
* Default: `"cache/invariant"`
* Environment: `FOUNDRY_INVARIANT_FAILURE_PERSIST_DIR`

Directory where invariant failures are recorded and replayed.

When an invariant test fails, its call sequence is saved under `failures/<contract>` in
this directory and replayed first the next time the test runs, so the test keeps failing
until the bug is fixed. `forge clean` removes the directory.

#### `show_metrics`

* Type: boolean
* Default: `true`
* Environment: `FOUNDRY_INVARIANT_SHOW_METRICS`

Whether to collect and display per-selector metrics (calls, reverts and discards) in the
test report.

#### `timeout`

* Type: integer
* Default: none
* Environment: `FOUNDRY_INVARIANT_TIMEOUT`

Time limit, in seconds, for each invariant campaign; when set, the campaign runs until it
elapses.

A timed campaign keeps executing runs until the deadline instead of stopping after `runs`,
and is then reported with the runs it completed. The timeout also bounds shrinking: once
the campaign ends, shrinking the failures it found stops at most `timeout` seconds after
the campaign deadline, so a timed invariant test finishes within about twice its timeout. A
failure whose shrinking runs out of time is reported with the shortest call sequence
confirmed so far.

```toml
[invariant]
timeout = 300
```

#### `show_solidity`

* Type: boolean
* Default: `false`
* Environment: `FOUNDRY_INVARIANT_SHOW_SOLIDITY`

Whether to display counterexamples as Solidity calls.

#### `max_time_delay`

* Type: integer
* Default: none
* Environment: `FOUNDRY_INVARIANT_MAX_TIME_DELAY`

Maximum time, in seconds, that may elapse between generated calls.

When set above 0, `block.timestamp` advances by a random amount, from 0 up to this value,
before each generated call, and the delays add up over a run. When unset or 0, calls do
not advance time.

#### `max_block_delay`

* Type: integer
* Default: none
* Environment: `FOUNDRY_INVARIANT_MAX_BLOCK_DELAY`

Maximum number of blocks that may elapse between generated calls.

When set above 0, `block.number` advances by a random amount, from 0 up to this value,
before each generated call, and the delays add up over a run. When unset or 0, calls do
not advance the block number.

#### `check_interval`

* Type: integer
* Default: `1`
* Environment: `FOUNDRY_INVARIANT_CHECK_INTERVAL`

Number of calls to execute between invariant assertions.

* `0`: only assert after the last call of each run (fastest, but may not identify the exact
  call that broke the invariant).
* `1`: assert after every call (most precise).
* `N`: assert after every `N`th call and always after the last call.

For example, `check_interval = 10` asserts after calls 10, 20, 30 and so on, and after the
last call.

#### `call_gas_limit`

* Type: integer
* Default: none
* Environment: `FOUNDRY_INVARIANT_CALL_GAS_LIMIT`

Gas limit for every call the invariant campaign makes after `setUp` and target selection.

It applies to handler calls, invariant checks, `afterInvariant`, and their replays and
shrinks. When unset, the campaign uses the project `gas_limit`. The setting never raises
the limit above `gas_limit`, and `setUp` always runs under `gas_limit`. A handler call
whose minimum gas is above the limit runs with that minimum instead: at the intrinsic
charge, network charges included, it has no gas left and reverts; at an EIP-7623 calldata
floor above the intrinsic charge, it keeps the difference and can still run, so large
fuzzed arrays do not stop the campaign.

Set it when a handler loops over a fuzzed bound: under a very large `gas_limit`, one such
call can run until the campaign timeout and the whole budget is lost. Echidna and Medusa
default to 12,500,000 gas per transaction.

```toml
[invariant]
call_gas_limit = 30_000_000
```
