Configuring Hedera JSON-RPC Relay endpoints
How to configure a JSON-RPC endpoint that enables the communication between EVM-compatible developer tools using the Hedera JSON-RPC Relay
Hedera JSON-RPC Relay is a server run by you on your own computer - decentralization for the win!
As such, it:
Is free to use on Hedera Previewnet and Hedera Testnet
Does not have any sign-up requirements
Does not have any rate limits
Requires several additional steps required to set it up, plus developer/command line skills
While this combination may be considered less user-friendly, it offers the highest levels of reliability among RPC endpoints.
This also makes the Hedera JSON-RPC Relay a good alternative for local development and testing; and also a potential option for contributing infrastructure to the Hedera ecosystem.
To connect to Hedera networks via your own instance of Hedera JSON-RPC Relay, use this URL when initializing the wallet/ web3 provider instance:
To get this service running, you will need to do the following pre-requisite steps:
(1) Clone the git project:
(2) Enter the directory that you have cloned, and install dependencies. It is recommended that you have NodeJS version 20
or later for this.
(3) Build the project, including its sub-packages.
(4) Create a file named .env
in the root directory of this project by copying .env.example
and naming it .env
.
Then set the following fields:
The following steps require that you already have an account on the Hedera network that you are connecting to. This account should be funded with some HBAR.
If you have yet to set one up, for Testnet you may use the Hedera Faucet. See Hedera Faucet instructions.
For either Previewnet or Testnet you may use the Hedera Portal. See Hedera Developer Portal Profile instructions.
Note that setting up a Mainnet account and funding it is out of scope for this article.
(5a) Copy your Account ID value into the .env
file in the OPERATOR_ID_MAIN
field.
(5b) Copy your account's DER Encoded Private Key into the .env
file in the OPERATOR_KEY_MAIN
field.
For example, if your account ID is 0.0.12345
, your private key is a1b2c3
, and you are connecting to Testnet, the .env
file should look like the following.
(6) Run npm run start
to start the RPC relay server.
Now you have an instance of Hedera JSON-RPC Relay running locally, and you are ready to send RPC requests to your selected Hedera network!
Full reference configuration options for Hedera JSON-RPC Relay: docs/configuration.md
.
Last updated