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:
http://localhost:7546http://localhost:7546http://localhost:7546To get this service running, you will need to do the following pre-requisite steps:
(1) Clone the git project:
git clone [email protected]:hashgraph/hedera-json-rpc-relay.git(2) Create or edit a file named
.envin 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" %}
{% @github-files/github-code-block url="https://github.com/hashgraph/hedera-json-rpc-relay/blob/f9d5ebaa80/docs/examples/.env.testnet.sample#L1-L5" %}
{% @github-files/github-code-block url="https://github.com/hashgraph/hedera-json-rpc-relay/blob/f9d5ebaa80/docs/examples/.env.previewnet.sample#L1-L5" %}
(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_KEYin the.envfile with it.(8) From the same screen, copy the value of "Account ID" and set the value of the
OPERATOR_ID_MAINvariable in the.envfile with it.(9) Run
npm installto install dependencies. Recommended that you have NodeJS version18or later for this.(10) Run
npm run setupto link dependencies within its sub-packages.(11) Run
npm run buildto build the full project.(12) Run
npm run startto 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