Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion src/content/docs/docs/guides/hardhat-node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ If you run this script multiple times, the output won't change:

<Run command="hardhat run my-script.ts" />

To have a locally simulated network that persists for longer than the duration of a single task, start a node in one terminal:
To run a simulated network that persists beyond a single task, start a node in one terminal:

<Run command="hardhat node" />

Expand All @@ -45,6 +45,39 @@ Then, in another terminal, run your script using the `--network localhost` optio

Now, if you run the script again while the node is running, you'll see the output change each time, as the state is preserved between runs.

## Configuring the local development node

There are two ways to configure the local development node:

1. By passing options to the `node` task
2. By configuring the `node` network in your Hardhat config

To pass options to the `node` task, you just run it with them, like this:

<Run command="hardhat node --chain-id 123" />

You can see the complete list of options by running:

<Run command="hardhat node --help" />

To configure it in your Hardhat config, add a `node` network. For example, to use the `123` chain ID:

```ts
// hardhat.config.ts
import { defineConfig } from "hardhat/config";

export default defineConfig({
networks: {
node: {
type: "edr-simulated",
chainId: 123,
},
},
});
```

The type of the `node` network config must be `edr-simulated`. To learn about all the config values, read the [Network configuration reference](/docs/reference/configuration#network-configuration).

## Running a development node programmatically

In addition to using the `hardhat node` task, you can start a development node programmatically using the Network Manager's `createServer` method. This method creates a local simulated network and exposes it through an HTTP-based JSON-RPC server, just like `hardhat node`.
Expand Down