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) Create or edit a file named
.env
in the root directory of this project, with the following fields set:
{% @github-files/github-code-block url="https://github.com/hashgraph/hedera-json-rpc-relay/blob/f9d5ebaa80/docs/examples/.env.mainnet.sample#L1-L5" %}
On either Hedera Previewnet or Hedera Testnet, continue on to step 3.
On Hedera Mainnet, you can proceed directly to step 8. You are advised to utilize an account already funded with HBAR for the OPERATOR_ID_MAIN
and_OPERATOR_KEY_MAIN
_ values. Please note that setting up a Hedera Mainnet account and funding it is out of scope for this article.
(3) Visit the Hedera Portal, and create a Testnet account. You will have the option to switch to Previewnet in subsequent steps.
(4) Copy-paste the confirmation code sent to your email:
(5) Fill out this form:
(6) In the top-left, select between Hedera Testnet (default) and Previewnet:
(7) From the next screen that shows your accounts, copy the value of the "DER-encoded private key" and replace
YOUR_OPERATOR_KEY
in the.env
file with it.(8) From the same screen, copy the value of "Account ID" and set the value of the
OPERATOR_ID_MAIN
variable in the.env
file with it.(9) Run
npm install
to install dependencies. Recommended that you have NodeJS version18
or later for this.(10) Run
npm run setup
to link dependencies within its sub-packages.(11) Run
npm run build
to build the full project.(12) Run
npm run start
to start the RPC relay server.
Now you're ready to connect to an RPC endpoint via a locally running instance of Hedera JSON-RPC Relay!
Full reference configuration options for Hedera JSON-RPC Relay: docs/configuration.md
.
Last updated