Configuring Hardhat with Hiero Local Node: A Step-by-Step Guide
Last updated
Was this helpful?
Last updated
Was this helpful?
Developers building smart contracts on Hedera often use the Hedera JSON-RPC Relay to enable Ethereum tools like Hardhat. In this post, we'll walk through how to set up Hardhat to work with the Hiero Local Node, allowing for local deployment, debugging, and testing of smart contracts without using testnet resources.
Not sure whether to use the Hiero Local Node, Hashio, or a custom relay setup? Read this comparing the different options.
Basic understanding of smart contracts.
Basic understanding of and JavaScript.
Basic understanding of and .
ECDSA account from the .
Hedera provides a local node configuration that includes a mirror node, a consensus node, and the JSON-RPC relay. You can run it via npm
.
Clone, install, and run the node:
Once all the containers have started, the Hiero Local Node is up and running. This includes a Consensus Node, Mirror Node and explorer, JSON RPC Relay, Block Node, Grafana UI, and Prometheus UI.
This command will also generate accounts on startup, which we will use later in our hardhat.config.js
.
If you don’t already have a Hardhat project, create one:
Make sure to select "Create a JavaScript project" and accept the default values. Hardhat will configure your project correctly and install the required dependencies like hardhat
and @nomicfoundation/hardhat-toolbox
(This includes plugins for Ethers, Waffle, Chai, and more).
Update your config to include the Hiero Local Node as a custom network:
🔍 Key Highlights
Network config: local
url: 'http://localhost:7546'
:
➤ This is the Hedera JSON-RPC Relay endpoint provided by the local node (via Docker). It enables Ethereum-compatible tools like Hardhat and Ethers.js to interact with the Hedera network.
accounts
:
➤ Two predefined ECDSA private keys provided by the Hiero Local Node.
➤ These accounts are already funded, and can be used immediately to deploy and interact with smart contracts.
chainId: 298
:
➤ This is the chain ID used by the Hiero Local Node to distinguish it from mainnet (295) or testnet (296).
Set paths:
./contracts
: Where your smart contracts are located.
./tests
: Directory for writing and running Hardhat tests.
./cache
& ./artifacts
: Manage build outputs and compilation caching to speed up repeated runs.
Default network: "local"
Automatically uses the local Hedera environment for all tasks like compiling, deploying, testing, and scripting.
Want to take your local development setup even further? Here are some excellent tutorials to help you dive deeper into smart contract development on Hedera using Hardhat and Ethers.js:
Learn how to create a basic ERC-721 NFT, mint it, and burn it on Hedera.
Extend your NFT with features like pausing, setting token URIs, and restricting minting to specific roles.
Learn how to add upgradability to your smart contracts using OpenZeppelin’s UUPS proxy pattern on Hedera.
A hands-on guide to spinning up a local Hedera test environment with a built-in JSON-RPC Relay. Perfect for fast, zero-cost smart contract development and testing.
Writer: Michiel, Developer Relations Engineer
Editor: Krystal, Technical Writer
|
|