Skip to content

Simulated Networks by EDR

Hardhat can simulate Ethereum and Layer 2 blockchains locally, a feature powered by Nomic Foundation’s Ethereum Development Runtime, or EDR.

This document explains how network simulations work. For a full list of features, check out the reference documentation.

Simulated networks are in-process blockchains that run entirely on your local machine.

Unlike connecting to a remote node through JSON-RPC, simulated networks give you complete control over the blockchain state, block production, and transaction execution. They’re faster and free to use.

The only difference between a blockchain simulated by EDR and a production one is that EDR requires no consensus mechanism or peer-to-peer network, as it’s run by a single process each time.

When you call await network.connect() with a Network Config of type edr-simulated, Hardhat creates a new, independent blockchain simulation. Each simulation is isolated, so you can create multiple simulations simultaneously without them interfering with each other.

You can use simulated networks in two ways:

When you run your tests or scripts, Hardhat automatically creates an in-process simulated network. For example:

import { network } from "hardhat";
const connection = await network.connect();

This creates a new blockchain simulation based on the Network Config specified in your configuration file or via the --network flag.

You can also run a simulated network as a standalone process that exposes a JSON-RPC interface over HTTP:

Terminal window
npx hardhat node

This starts a local node at http://127.0.0.1:8545 that you can connect to with wallets, applications, Hardhat, or other tools.