blog

How To Leverage Hedera for Efficient Web3 Development: A Dive into JSON-RPC EVM Tooling

Written by Dan Kazenoff | Feb 15, 2024 6:27:31 PM

 

Anyone who has built applications or been a user of Ethereum mainnet is likely familiar with its pain points. While Ethereum's security and decentralization are nearly unparalleled, Ethereum doesn’t come without challenges. Layer 2 solutions like Arbitrum, Optimism, Scroll, and sidechains like Polygon offer interesting alternatives within the EVM landscape. However, this post shifts the focus to a different ecosystem altogether: Hedera Hashgraph.

Why Hedera? A Look Beyond Ethereum Mainnet

Hedera stands out not just technically but also in its strategic focus. Here are a few reasons why developers and enterprises are choosing to build on Hedera:

  • High Throughput, Fast Finality, and Low Fees: Unlike Ethereum's notorious gas fees and network congestion (which invariably percolates upwards even to the more affordable L2s), Hedera boasts high transaction throughput and predictably low fees, making it economically viable for startups and enterprises alike. Specifically, Hashgraph achieves high throughput with 10,000+ transactions per second today, and 3-5 second finality. Learn more on Hedera’s unique “Gossip-about-Gossip” protocol here.  
  • Unique Market Focus: While Ethereum broadly targets decentralized applications, Hedera has carved niches in sectors like supply chain management, where its low-cost transactions and fast finality are particularly beneficial. This focus on specific markets such as supply chain underscores Hedera's strategic positioning beyond the generalist approach of Ethereum.
  • Sustainability, Governance, and Security: Hedera's governance model, led by a council of renowned organizations such as Avery Dennison and Standard Bank, offers a unique blend of decentralization with structured oversight, enhancing network trustworthiness. This is all underpinned by its proof-of-stake consensus mechanism - which is not just energy-efficient but also strategically aligns with the growing demand for green technologies in blockchain.
Overview: Integrating Validation Cloud's JSON-RPC with Hedera

For developers seeking to harness Hedera's advantages, the integration of JSON-RPC via Validation Cloud opens up a world of possibilities. This interface allows for seamless interaction with the Hedera network, leveraging familiar EVM tools and libraries to build and deploy your Web3 applications with ease.

The JSON-RPC relay for Hedera, accessible through Validation Cloud, provides a robust gateway for developers to engage with the Hedera network using popular development tools like HardHat and Foundry. This means you can develop smart contracts, deploy decentralized applications, and interact with the Hedera network using the same EVM-compatible tools you're already familiar with, but with the added benefits of Hedera's ecosystem.

To get started, developers can refer to the comprehensive documentation available at Validation Cloud's JSON-RPC Relay API. Here, you'll find detailed instructions on setting up your development environment, connecting to the Hedera network, and executing transactions or smart contracts. Whether it's deploying your first smart contract on Hedera or querying the state of a contract, the documentation guides you through each step with clarity and precision.

Setting up your Hedera Hashgraph Environment

Before you begin, ensure you have Node.js, along with the web3 node package installed on your machine. (Of course, other frameworks can be utilized but for this post we focus on Node!). This will allow you to run JavaScript programs that interact with the Hedera network through JSON-RPC. You'll also need to set up an account on Validation Cloud to obtain your JSON-RPC endpoint and API keys.

Example 1: Connecting to the Hedera Network

The most basic step to start with is establishing a connection to the Hedera network. This involves initializing a web3 instance with the Hedera JSON-RPC endpoint provided by Validation Cloud. The web3 node package will be required.

Example 2: Querying Account Balance

Suppose you want to build an accounting application to track balances over time. To query the balance of an account, you can use the getBalance method provided by web3.js. This method requires the account address as a parameter.

Example 3: Sending a Transaction

Another critical element of any web3 application is token transfers. Sending a transaction involves creating and signing a transaction object with your wallet, and then broadcasting it to the network. Since drawing a balance from a wallet is involved in the below example, we are dealing with the sensitivity of a private key. In my case, I prefer to invoke the private key from an environment file for some basic security. I would rather not have the private key displayed directly in my code, and neither should you. I will choose to install “dotenv” to easily invoke environment variables. Here's a simplified example of how to send HBAR from one account to another:

 

More information on getting started can be found on the Hedera documentation pages: https://docs.hedera.com/hedera/#set-up-your-environment 

Start Building on Hedera

For developers seeking familiarity with high-performance blockchains, Hedera offers a compelling case. Its unique focus on specific markets, coupled with high-performance infrastructure and a developer-friendly approach through tools like Validation Cloud's JSON-RPC relay, makes Hedera an attractive platform for building the next generation of decentralized applications. Embrace the shift and explore what Hedera has to offer to your Web3 development journey. Get started for free at validationcloud.io.

About Validation Cloud

Validation Cloud is a Web3 data streaming and infrastructure company that connects organizations into Web3 through a fast, scalable, and intelligent platform. Headquartered in Zug, Switzerland, Validation Cloud offers highly performant and customizable products in staking, node, and data-as-a-service. Learn more at Validationcloud.io LinkedIn | X