Configuration Overview
TheLocalNodeManager
constructor accepts a NodeConfig
object that allows you to customize the behavior of your local Anvil node. All configuration options are optional, with sensible defaults provided.
Basic Configuration
NodeConfig Type
Configuration Options
Network Settings
The chain ID for the network. Common values:
1
- Ethereum Mainnet8453
- Base Mainnet84532
- Base Sepolia31337
- Default Hardhat/Anvil
Specific hardfork to use. Options:
"london"
, "berlin"
, "cancun"
Port Configuration
Fixed port number for the RPC server. If not specified, a port will be dynamically allocated.
Port range for automatic port selection when
port
is not specified.Fork Mode
URL to fork from (e.g., mainnet or testnet RPC endpoint). Enables fork mode.
Specific block number to fork from. Must be used with
forkUrl
.Retry interval for fork requests in milliseconds.
Account Configuration
Mnemonic phrase for generating test accounts.
Default balance for test accounts in wei.
Number of test accounts to generate.
Mining Configuration
Time between blocks in seconds. Set to
0
for instant mining (default).Disable automatic mining. Blocks must be manually mined with
node.mine()
.Gas limit per block.
Configuration Examples
Basic Local Testing
Fork Mainnet
Base Sepolia Fork
Manual Mining Mode
Fixed Port Configuration
Custom Port Range
Environment Variables
It’s recommended to use environment variables for sensitive or environment-specific configuration:Default Values
When no configuration is provided, these defaults are used:- chainId:
84532
(Base Sepolia) - portRange:
[10000, 20000]
- defaultBalance:
10000 ETH
per account - totalAccounts:
10
- blockTime:
0
(instant mining) - noMining:
false
Best Practices
1
Use Environment Variables
Store RPC URLs, mnemonics, and API keys in environment variables
2
Fork for Integration Tests
Use fork mode to test against real mainnet/testnet state
3
Dynamic Ports for Parallel Tests
Let the system allocate ports automatically for parallel test execution
4
Consistent Configuration
Share configuration between tests using a common config file
Next Steps
- Learn about LocalNodeManager API
- See complete examples