Overview
Hiero’s JSON-RPC relay provides a familiar interface for EVM developers by supporting standard Ethereum JSON RPC methods. This compatibility means you can use popular EVM development tools (like Hardhat, Truffle, or Foundry) and wallets (like Metamask) to interact with Hedera’s network. However, Hedera’s unique state management model affects how you retrieve historical data and verify states, requiring a shift in approach from the standard EVM workflow.Key Relay Features
The relay offers several advanced features that enhance dApp development on Hedera:Real-Time Data and Event Filtering
The relay provides robust support for real-time data streaming and event filtering through its WebSocket server and Filter API methods. This allows applications to listen for on-chain events and receive updates as they happen.- WebSocket Support (
eth_subscribe): Developers can establish a WebSocket connection to the relay (default:ws://localhost:8546) to subscribe to logs and newHeads events. This is ideal for applications that need to react instantly to new blocks or specific contract events. This functionality is enabled by HIP-694. - Filter API Methods: The relay supports the standard Ethereum Filter API, including
eth_newFilter,eth_getFilterChanges, andeth_getFilterLogs. These methods allow you to create and query filters for historical logs and pending transactions, providing a powerful way to track contract activity.
Paymaster Support for Gasless Transactions
The JSON-RPC relay supports a paymaster feature, enabling gasless transactions for users. When this feature is enabled, the relay operator can sponsor transaction fees, allowing dApp users to interact with smart contracts without needing to hold HBAR for gas. This is ideal for improving user onboarding and creating seamless application experiences. Key features of paymaster support include:- Gasless Transactions: Users can send transactions with a gas price of 0.
- Operator-Sponsored Fees: The relay operator covers the HAPI and Ethereum fees.
- Flexible Configuration: Operators can enable paymaster support for all transactions (wildcard) or restrict it to a whitelist of specific smart contract addresses.
Testing with Network Forking
Hedera now supports network forking, which allows you to test smart contracts against a live network’s state without executing transactions on the actual network. This is a feature for development and debugging, as it lets you simulate transactions and contract interactions in a realistic environment. You can fork the Hedera network using both Hardhat and Foundry. For detailed instructions and examples, please refer to our tutorials:- Forking the Hedera Network for Local Testing (Core Concepts)
- How to Fork the Hedera Network with Hardhat (Basic ERC-20)
- How to Fork the Hedera Network with Hardhat (Advanced HTS)
- How to Fork the Hedera Network with Foundry (Basic ERC-20)
Ethereum RPC API Behavior via JSON-RPC Relay
On Ethereum, methods likeeth_getBlockByNumber return the true value of stateRoot that enables direct historical state verification. Hiero’s JSON-RPC relay, however, returns the root hash of an empty Merkle trie for the stateRoot value for compatibility. Instead of relying on it, you should query Hedera’s mirror nodes for historical states, event logs, and transaction details.
Example JSON-RPC Query Request
A request toeth_getBlockByNumber returns a stateRoot, but it’s not useful for historical verification on Hedera. Instead, use mirror node REST APIs to fetch the necessary historical information.
stateRoot value.
Endpoints
The JSON RPC Relay methods implement a subset of the standard method:Gossip Methods
These methods track the head of the chain. This is how transactions make their way around the network, find their way into blocks, and how clients find out about new blocks.| Method | Static Response Value |
|---|---|
eth_blockNumber | N/A |
eth_sendRawTransaction | N/A |
State Methods
Methods that report the current state of all the data stored. The “state” is like one big shared piece of RAM, and includes account balances, contract data, and gas estimations.| Method | Static Response Value |
|---|---|
| eth_getBalance | n/a |
| eth_getStorageAt | n/a |
| eth_getTransactionCount | n/a |
| eth_getCode | n/a |
| eth_call | n/a |
| eth_estimateGas | generates and returns an estimate of the gas required for the transaction to complete |
History Methods
Fetches historical records of every block back to genesis. This is like one large append-only file, and includes all block headers, block bodies, uncle blocks, and transaction receipts.| Method | Static Response Value |
|---|---|
| eth_getBlockTransactionCountByHash | n/a |
| eth_getBlockTransactionCountByNumber | n/a |
| eth_getUncleCountByBlockHash | null |
| eth_getUncleCountByBlockNumber | 0x0 |
| eth_getBlockByHash | stateRoot is always zero |
| eth_getBlockByNumber | stateRoot is always zero |
| eth_getTransactionByHash | n/a |
| eth_getTransactionByBlockHashAndIndex | n/a |
| eth_getTransactionByBlockNumberAndIndex | n/a |
| eth_getTransactionReceipt | n/a |
| eth_getUncleByBlockHashAndIndex | null |
| eth_getUncleByBlockNumberAndIndex | null |
Supported EVM Development Tools
| Feature | web3js | Truffle | ethers | Hardhat | Remix IDE | Foundry |
|---|---|---|---|---|---|---|
| Transfer HBARS | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Contract Deployment | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Can use the contract instance after deploy without re-initialization | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Contract View Function Call | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Contract Function Call | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Debug Operations** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
**Debug operations are supported via the
debug_traceTransaction and debug_traceBlockByNumber methods. To enable these methods, you must set DEBUG_API_ENABLED=true in your relay configuration. For more information, see the debugging documentation.Note: Development tools usually make a lot of requests to certain endpoints, especially during contract deployment. Be aware of rate limiting when deploying multiple large contracts.Note: Enable development mode to correctly assert revert messages of contract calls with hardhat-chai-matchers.