Skip to main content

JSON-RPC Relay

Hgraph's Hedera JSON-RPC relay brings new levels of EVM compatibility to the ecosystem, enabling seamless integration with Ethereum-based tools and frameworks.

The Hedera JSON-RPC Relay enables developers to interact with the Hedera network using Ethereum-compatible JSON-RPC methods. This allows seamless integration of Ethereum-based tools, such as wallets and developer frameworks, with the Hedera blockchain. View the official repository on Hiero.

The relay follows the JSON-RPC 2.0 Specification and implements a subset of the Ethereum JSON-RPC APIs to facilitate smart contract interactions and transaction execution.

Hgraph offers reliable, fast access to the Hedera JSON-RPC relay for all supported subscription plans.

Requirements

The Hedera JSON-RPC relay is available on the following Hgraph subscription plans:

  • Developer
  • Startup
  • Premium
  • Enterprise

See more information on our pricing page.

API Endpoints

You can interact with the JSON-RPC relay through the following endpoints:

Testnet Endpoint

https://testnet.hedera.api.hgraph.io/rpc

Mainnet Endpoint

https://mainnet.hedera.api.hgraph.io/rpc

Note: Currently, /rpc is used for JSON-RPC relay endpoints.

Authentication

  • API requests require an API key for authentication.
  • You can obtain an API key by creating an account!
  • Production API keys start with pk_prod_ followed by a unique identifier.

How to Use the API Key

Include the API key in your URL for path-based authentication:

https://testnet.hedera.api.hgraph.io/v1/<YOUR_API_KEY>/rpc

Testing the Relay

You can test the JSON-RPC relay by making simple curl requests.

Example 1: Get Network Chain ID

curl -X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"1","method":"eth_chainId","params":[]}' \
https://testnet.hedera.api.hgraph.io/v1/<YOUR_API_KEY>/rpc

Response:

{
"result": "0x128", // 296 in decimal for testnet
"jsonrpc": "2.0",
"id": "1"
}

Example 2: Get Current Gas Price

curl -X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"2","method":"eth_gasPrice","params":[]}' \
https://mainnet.hedera.api.hgraph.io/v1/<YOUR_API_KEY>/rpc

Response:

{
"result": "0x5879c3d800", // Gas price in wei
"jsonrpc": "2.0",
"id": "2"
}

Example 3: Get Latest Block

curl -X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"3","method":"eth_getBlockByNumber","params":["latest", false]}' \
https://mainnet.hedera.api.hgraph.io/v1/<YOUR_API_KEY>/rpc

The response will include block details such as hash, number, timestamp, and transaction information.

Supported JSON-RPC Methods

The relay supports a subset of Ethereum JSON-RPC methods for interacting with the Hedera network. These include:

MethodDescription
eth_chainIdReturns the chain ID of the connected network.
eth_getBlockByNumberRetrieves information about a specific block.
eth_getTransactionByHashReturns transaction details based on a transaction hash.
eth_callExecutes a smart contract read operation.
eth_sendRawTransactionSends a signed transaction to the network.
eth_gasPriceReturns the current gas price in wei.

For a full list of supported methods, refer to the Hedera JSON-RPC Relay API documentation.


For further details and technical insights, refer to the official Hedera JSON-RPC Relay GitHub repository.

Support

For any issues or questions, contact support.