The following environment variables can be used to configure the hardhat node:
INFURA_TOKEN
- Token for Infura providerALCHEMY_TOKEN
- Token for Alchemy providerETH_RPC_URL
- Custom Ethereum RPC URLDONT_SET_CHAIN_ID
- Set to any value to prevent setting chainId (useful when forking)HARDFORK
- Specify the hardfork to use (defaults to "cancun")
The following node types are available as different Docker image tags:
:latest
or:<version>
- Mainnet fork node:<version>-scratch
- Fresh node without forking:<version>-hoodi
- Hoodi network fork node
The Hardhat node comes with the following default configuration:
- 30 test accounts
- Initial base fee per gas set to 0
- Mocha timeout set to 5 minutes
- Solidity version 0.8.25
With Infura
docker run -e INFURA_TOKEN=your_token -p 8545:8545 -it --rm ghcr.io/lidofinance/hardhat-node:2.23.0
With Alchemy:
docker run -e ALCHEMY_TOKEN=your_token -p 8545:8545 -it --rm ghcr.io/lidofinance/hardhat-node:2.23.0
With custom provider:
docker run -e ETH_RPC_URL=your_url -p 8545:8545 -it --rm ghcr.io/lidofinance/hardhat-node:2.23.0
If you don't need to fork mainnet, and you only want to work with the -scratch
node:
docker run -p 8545:8545 -it --rm ghcr.io/lidofinance/hardhat-node:2.23.0-scratch
If you want to fork hoodi use -hoodi
node, for example:
docker run -e ETH_RPC_URL=your_url -p 8545:8545 -it --rm ghcr.io/lidofinance/hardhat-node:2.23.0-hoodi
There might an issue when forking hardhat node with a hardhat node which causes an error like:
The response reported error `-32000`: `header not found`. (optional data: None). Request: {"jsonrpc":"2.0","method":"eth_getBalance","params":["0x61097ba76cd906d2ba4fd106e757f7eb455fc295","0x15062e6"],"id":275}
To fix this chainId
must not be set in the forked node. To do so set DONT_SET_CHAIN_ID
env variable, e.g. DONT_SET_CHAIN_ID=1
.
- set the new version in package.json
- run
pnpm install
- create new branch
feat/hardhat-<version>
- create a PR
- merge the PR
- create a new tag with the version
git tag -a <version> -m "Hardhat version <version>"
- push the tag
git push --tags