diff --git a/src/content/docs/docs/guides/hardhat-node.mdx b/src/content/docs/docs/guides/hardhat-node.mdx index 1823b2165..eef6fe5cb 100644 --- a/src/content/docs/docs/guides/hardhat-node.mdx +++ b/src/content/docs/docs/guides/hardhat-node.mdx @@ -35,7 +35,7 @@ If you run this script multiple times, the output won't change: -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: @@ -45,6 +45,44 @@ 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 three 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, which is the network used by default +3. By providing a network config name with `--network` + +To pass options to the `node` task, you just run it with them, like this: + + + +You can see the complete list of options by running: + + + +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). + +Finally, you can configure it using `--network` and the name of the network: + + + ## 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`. @@ -85,4 +123,4 @@ Run this script with: -While the server is running, you can connect to it through HTTP, for example using `--network localhost`, or any client with its address and port. +While the server is running, you can connect to it through HTTP, for example using `--network localhost`, or with any HTTP client using the server's address and port.