Introduction
As the Hedera ecosystem continues to grow, operators of the Hedera JSON-RPC Relay face new challenges, particularly in managing the costs associated with user transactions—especially in public environments. Imagine this: you have allocated a daily, monthly, or yearly HBAR budget and want to ensure it isn’t exceeded. Everything is running smoothly until certain users start submitting abnormally high-cost transactions. These transactions quickly deplete your HBAR resources, leaving less for other users and leading to an unfair distribution of the budget.
To address this challenge, we have re-engineered our previous HBAR rate limiter. The earlier version simply tracked a single total limit over a specified period. In contrast, the new design introduces a customizable Tiered HBAR Rate Limiter, integrated into the relay, allowing for more granular control and flexibility in managing rate limits. This new feature empowers operators to take control of their spending by categorizing users into tiers with defined spending limits.
In this blog post, we’ll explore how this tiered approach works, why it matters, and how operators can use it to protect their financial resources while supporting the Hedera ecosystem.
Understanding the Economic Model
Before diving into the functionality of the HBAR rate limiter, let’s establish some context regarding the relay’s economic model and how it compares to similar systems, such as Ethereum.
The Role of the Hedera JSON-RPC Relay
The Hedera JSON-RPC Relay serves as a critical bridge, connecting EVM-based applications to the Hedera network. By translating Ethereum Virtual Machine (EVM) JSON-RPC calls into Hedera-compatible requests, the relay enables dApp developers to leverage Hedera’s benefits seamlessly without modifying their existing codebases. These codebases are often built using third-party tools developed for the Ethereum network, such as Ethers.js and Web3.js.
EVM Equivalence and Gas Costs
To maintain EVM equivalence, gas costs charged to users reflect the computational work required, similar to Ethereum. However, in addition to executing transactions within the EVM, certain operations require additional Hedera File Service (HFS) transactions to process large requests.
For example, when deploying a smart contract with bytecode exceeding 5,120 bytes, the following operations must be performed:
- The bytecode is split into
Nchunks of 5,120 bytes. - A
FileCreatetransaction is executed to create a temporary file with the first chunk’s contents (costing approximately $0.05). - The remaining
N-1chunks are added to the file viaFileAppendtransactions (each append costing approximately $0.05). - The created file is read by the consensus node to retrieve the full contract bytecode and pass it to the EVM for execution.
- Once the contract is deployed, a
FileDeletetransaction ($0.007) is executed to remove the temporary file.
Who Pays for These HFS Transaction Fees?
Currently, the relay operator bears the costs of these additional HFS transactions. In most cases, these costs are negligible. However, some users may repeatedly deploy large contracts (requiring multiple file transactions on Hedera) or submit high transaction volumes. Without a proper rate-limiting mechanism, these activities can lead to costs that exceed an operator’s initial estimates, quickly becoming unsustainable.
Introducing the Tiered HBAR Rate Limiter
To address these cost management challenges, we developed the Tiered HBAR Rate Limiter. By assigning different spending limits to users based on their tier, we enable sustainable and predictable cost management while still supporting the network’s growth.
How Does the Tiered System Work?
The tiered system assigns users (or groups of users) to specific HBAR spending plans tailored to their behavior and contribution to the network. Think of it like Netflix subscriptions—spending plans can be assigned individually or to groups, similar to personal and family subscription categories.
Basic Tier: General Users
By default, every new user who sends a request to our relay is automatically assigned a unique spending plan under the `BASIC` tier (**Tier 3**). This tier is designed for users whose transactions fall within a predictable HBAR spending quota—whether daily, weekly, or monthly. Operators can calculate these quotas based on the expected number of users and typical transaction costs. With built-in monitoring tools, operators can track and identify users who exceed these expectations.
> **Example**: A casual dApp user submitting regular transactions would likely remain in Tier 3. However, a user deploying multiple large contracts might trigger a review of their activity.
### **Extended Tier: Supported Projects**
Users who exceed the usual activity levels but contribute significantly to the network may qualify for an `EXTENDED` tier (**Tier 2**) spending plan. This tier is ideal for projects that require higher resource usage—such as those running resource-intensive dApps or conducting large-scale testing—while still aligning with the operator’s goals.
> **Example**: An innovative DeFi platform performing large-scale testing on Hedera could qualify for Tier 2, allowing greater flexibility without completely removing cost constraints.
### **Privileged Tier: Trusted Partners**
The `PRIVILEGED` tier (**Tier 1**) is reserved for strategic or critical partnerships, providing users with a significantly higher spending limit. This tier is intended for trusted collaborators whose operations are integral to the operator’s success or the broader Hedera ecosystem.
> **Example**: A major enterprise partner integrating Hedera into its infrastructure might be assigned to Tier 1 to facilitate unrestricted development and usage.
—
## **Configuring the Rate Limiter**
Operators can fine-tune the rate limiter to match their specific needs. The relay’s documentation provides a comprehensive guide to configuration options, including:
– Defining limits for different tiers.
– Assigning EVM addresses to pre-configured spending plans.
– Tracking user activity.
– Customizing the limit duration.
Explore the detailed configuration guide in the GitHub repository:
[https://github.com/hashgraph/h…](https://github.com/hashgraph/h…)
By adjusting these settings, operators can balance cost control with the flexibility needed to accommodate diverse user needs. This system also eliminates the need to run multiple RPC relay instances to provide different service levels for different users.
—
## **Benefits of the Enhanced HBAR Rate Limiter**
The tiered spending system offers several advantages for relay operators:
– **Cost Control**: Operators can define and enforce spending limits for different user groups, ensuring expenses remain manageable.
– **Flexibility**: High-value users or strategic projects can receive additional resources while maintaining overall budget discipline.
– **User Management**: With monitoring tools, operators can easily track activity, adjust user tiers, and allocate resources efficiently.
– **Transparency**: By clearly communicating spending tiers, operators set user expectations and encourage responsible usage.
—
## **Conclusion**
The newly redesigned HBAR rate limiter is a powerful tool for JSON-RPC Relay operators to control costs and manage user activity effectively. By assigning tiered spending limits to different user groups, operators can support the growth of the Hedera ecosystem while safeguarding their financial resources and ensuring fair allocation.
—
## **Call to Action**
If you’re a relay operator, we encourage you to explore the new rate limiter features and consider how they can benefit your operations. For users, understanding these tiers can help align your activity with operator policies and optimize your interaction with the Hedera network.
For a detailed configuration guide, visit the GitHub repository: [here](https://github.com/hashgraph/h…).
—
This version keeps the formatting clean for easy pasting into CRAFT. Let me know if you need any tweaks!