Skip to main content

Configuration Overview

The LocalNodeManager 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

number
default:"84532"
The chain ID for the network. Common values:
  • 1 - Ethereum Mainnet
  • 8453 - Base Mainnet
  • 84532 - Base Sepolia
  • 31337 - Default Hardhat/Anvil
string
Specific hardfork to use. Options: "london", "berlin", "cancun"

Port Configuration

number
Fixed port number for the RPC server. If not specified, a port will be dynamically allocated.
[number, number]
default:"[10000, 20000]"
Port range for automatic port selection when port is not specified.

Fork Mode

string
URL to fork from (e.g., mainnet or testnet RPC endpoint). Enables fork mode.
bigint
Specific block number to fork from. Must be used with forkUrl.
number
Retry interval for fork requests in milliseconds.

Account Configuration

string
Mnemonic phrase for generating test accounts.
bigint
default:"10000 ETH"
Default balance for test accounts in wei.
number
default:"10"
Number of test accounts to generate.

Mining Configuration

number
default:"0"
Time between blocks in seconds. Set to 0 for instant mining (default).
boolean
default:"false"
Disable automatic mining. Blocks must be manually mined with node.mine().
bigint
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