API to create an in-process Hardhat network from a standalone program #5128
-
Using ganache, it is easy to create an ephemeral network from JavaScript:
How to do the same using hardhat-network? Hardhat will do it for you when running scripts in a Hardhat project, but I want to use it in a standalone program, not part of a project and run directly using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There is not an easy way to create an ephemeral network based on a passed in config. You can import const hre = require("hardhat"); However this reads the config from a Hardhat config file in the current working directory - not what you are after. It is also limited to one Hardhat network per node process. See the docs for more details on use a Hardhat node from a script. This is a limitation we explicitly looking to overcome in Hardhat v3, which we are actively working on. |
Beta Was this translation helpful? Give feedback.
There is not an easy way to create an ephemeral network based on a passed in config. You can import
hardhat
in a standalone script that will run a node:However this reads the config from a Hardhat config file in the current working directory - not what you are after. It is also limited to one Hardhat network per node process.
See the docs for more details on use a Hardhat node from a script.
This is a limitation we explicitly looking to overcome in Hardhat v3, which we are actively working on.