Skill 7.3.2

Configure development node accounts, mining and forking

Key Concepts

By default, development nodes use automine: every transaction is mined in its own block immediately. Interval mining produces blocks on a timer, which is useful for testing pending transactions and front-ends, and Geth's developer mode takes --dev.period to set block time. Development JSON-RPC methods control the chain: evm_mine, evm_increaseTime, evm_snapshot and evm_revert, and Hardhat's hardhat_setBalance and hardhat_impersonateAccount.

Forking starts a local chain that reads the state of a live network from an RPC endpoint on demand: npx hardhat node --fork <rpc-url>, optionally with --fork-block-number to pin a block for reproducible results (Anvil uses --fork-url). Tests can then interact with real deployed contracts and impersonate real accounts without spending anything.

The node's JSON-RPC server should listen only on 127.0.0.1. Exposing a node with unlocked or well-known accounts to a network lets anyone send transactions from them; the same applies to production nodes with personal APIs enabled.