get_foundry_network_name

Documentation for eth_defi.chain.get_foundry_network_name function.

get_foundry_network_name(chain_id)

Return Foundry’s fork-cache network directory name for a chain id.

Anvil stores its fork RPC cache under ~/.foundry/cache/rpc/<network>/<block>/ keyed by Foundry’s own chain name (e.g. mainnet for Ethereum, bsc for BNB Smart Chain), not our CHAIN_NAMES display name. Use this to locate or seed a chain’s fork cache directory (see eth_defi.testing.rpc_cache).

Parameters

chain_id (int) – EVM chain id.

Returns

The Foundry network directory name, or None when not recorded in FOUNDRY_NETWORK_NAMES (Foundry then falls back to the numeric chain id as the directory name).

Return type

Optional[str]