Mainnet Fork Configuration Generator
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
Mainnet Fork Configuration Generator is a read-only developer tool that generates configuration files for creating local mainnet forks using Hardhat, Anvil (Foundry), and Ganache. It reads the current chain state to determine the latest block number and chain ID, validates user-provided fork block numbers, and generates ready-to-use configurations for three popular fork tools. The tool also supports specifying accounts to impersonate, generating the necessary hardhat_impersonateAccount scripts. It helps developers quickly set up local testing environments that mirror mainnet state, enabling safe contract testing, debugging, and development without spending real gas or affecting the live network.
HOW TO USE
Connect your EVM-compatible wallet via the BGWallet bridge and select the network you want to fork. Enter a fork name, optionally specify a fork block number (leave blank for latest), and optionally list accounts to impersonate (one per line). Click "Generate Fork Config" to produce the configurations. Results include a Hardhat configuration snippet for hardhat.config.js, an Anvil command-line invocation, a Foundry configuration for foundry.toml, and an impersonation script for unlocking specified accounts. The tool also provides copy buttons and usage instructions for deploying and testing on the fork. All analysis is read-only—no signatures or transactions are submitted.
TECHNICAL MECHANISM
The tool uses ethers.js v5.7.2 to fetch chain state from the provider. It retrieves the current block number via provider.getBlockNumber() and the chain ID via provider.getNetwork(). If the user provides a fork block number, the tool validates it against the current block number to ensure it's not in the future. The tool fetches the block header using provider.getBlock(forkBlock) to confirm existence. For impersonation accounts, the tool validates each address format and generates hardhat_impersonateAccount RPC call snippets. The configuration generator produces three output formats: (1) Hardhat config with the forking block number and chain ID set; (2) Anvil command with --fork-url and --fork-block-number flags; (3) Foundry config with fork_block_number and fork_url settings. Each configuration includes placeholder text (MAINNET_RPC_URL) that the user must replace with their actual RPC endpoint. The impersonation script uses hardhat.network.provider.request to unlock accounts for testing. The tool does not store or persist any data—all results are generated on-demand and displayed in the UI.
WHAT IT CANNOT SEE
This tool has fundamental limitations that users must understand. It cannot actually deploy or run a mainnet fork—the tool generates configuration files but requires external infrastructure (Hardhat, Anvil, or Ganache) to run the fork. It cannot guarantee that the generated configuration will work without manual adjustment—different tool versions and network configurations may require additional settings. It cannot account for differences in fork behavior between tools—Hardhat, Anvil, and Ganache have different implementations and performance characteristics. It cannot impersonate accounts or send transactions on the fork—the tool only generates the script, it does not execute it. It cannot set up the fork's initial state beyond the specified block—the fork state is determined by the block number and RPC provider. It cannot handle contracts that depend on real-time oracles or off-chain data—forked environments may not reflect dynamic external data. It cannot automatically resolve complex dependency chains for forked contracts—some contracts may require additional setup or mock contracts. It cannot test state changes that require mining new blocks—the fork must be advanced manually. It cannot fork private or permissioned networks. The tool assumes the user has access to a reliable RPC endpoint and the necessary tooling installed.
PLEASE NOTE
This tool only supports EVM-compatible blockchains (Ethereum, Polygon, BSC, Avalanche C-Chain, Optimism, Arbitrum, and their testnets). Solana, Tron, Starknet, SUI, TON, Aptos, Bitcoin, Cosmos, and XRP are not supported. The tool is free, open-source, requires no API keys, and uses the wallet's native provider for all read operations. Always replace MAINNET_RPC_URL with your actual RPC endpoint before using the generated configurations.