QuickNode Now Supports Hedera Mainnet and Testnet

QuickNode Now Supports Hedera Mainnet and Testnet

As blockchain technology continues to evolve, the need for robust, efficient, and scalable infrastructure becomes increasingly important. QuickNode, a leading blockchain infrastructure provider, has recently announced support for Hedera Mainnet and Testnet. This development opens new avenues for developers looking to leverage Hedera's unique consensus mechanism and features. In this article, we'll explore what Hedera Hashgraph is, how to get started with Hedera on QuickNode, and the potential use cases for this integration.

What is Hedera Hashgraph?

Hedera Hashgraph is a revolutionary distributed ledger technology (DLT) that offers an alternative to traditional blockchain architectures. Developed by Dr. Leemon Baird, Hedera Hashgraph aims to overcome the limitations of existing blockchain systems, such as slow transaction speeds, high energy consumption, and lack of scalability.

How Hedera Hashgraph Works

Hedera Hashgraph utilizes a consensus algorithm called Hashgraph, which operates on a directed acyclic graph (DAG) structure rather than a linear chain of blocks. This allows for multiple transactions to be processed simultaneously, significantly increasing throughput and efficiency.

https://hedera.com/?ref=devsuite.hashnode.dev

  • Gossip About Gossip: In the Hashgraph protocol, nodes share information about transactions with one another using a technique known as "gossip about gossip." Each node randomly selects another node and shares all the information it knows, including the history of how it received the data. This creates a fast and efficient network for disseminating information.

  • Virtual Voting: Instead of requiring miners to reach consensus through energy-intensive processes, Hashgraph uses virtual voting. Each node records the history of interactions, and consensus is achieved through a mathematical process that determines the order of transactions based on the timestamps and historical data of the gossip protocol. This ensures fairness and security without the need for mining.

Key Features and Benefits of Hedera

  1. High Throughput: Hedera Hashgraph can handle thousands of transactions per second (tps), far exceeding the capabilities of many traditional blockchains. This makes it suitable for high-demand applications such as financial services and gaming.

  2. Low Latency: Transactions on Hedera achieve consensus within a few seconds, providing near-instantaneous confirmation. This is crucial for applications that require real-time responsiveness.

  3. Security: Hedera’s asynchronous Byzantine Fault Tolerance (aBFT) ensures high security and resilience against malicious attacks. The aBFT consensus algorithm is mathematically proven to be secure, offering a level of trust and reliability necessary for enterprise-grade applications.

  4. Energy Efficiency: Unlike proof-of-work blockchains that require significant computational power and energy, Hedera’s consensus mechanism is highly energy-efficient, making it an environmentally friendly option.

  5. Fairness: The Hashgraph consensus algorithm ensures fair ordering of transactions. By utilizing timestamps and consensus order, it prevents issues like front-running, where certain participants can gain unfair advantages by manipulating transaction order.

  6. Governance: Hedera is governed by a council of leading global organizations across multiple industries. This decentralized governance model ensures that no single entity has control over the network, promoting transparency and stability.

  7. Smart Contracts and Tokens: Hedera supports smart contracts and native tokenization, allowing developers to create complex decentralized applications (dApps) and digital assets on its platform.QuickNode’s Integration with Hedera

Hedera Hashgraph’s innovative approach to distributed ledger technology positions it as a leader in the field, offering solutions that traditional blockchains struggle to provide. Its combination of speed, security, and scalability makes it a powerful tool for developers looking to build the next generation of decentralized applications.

Why Choose QuickNode for Hedera Development?

Anyone interested in building on the Hedera network can easily get started by signing up for a QuickNode account and setting up a Hedera JSON-RPC endpoint. Here are the advantages of using QuickNode for Hedera development:

  1. Ease of Use: QuickNode provides an intuitive user interface that simplifies the process of connecting to Hedera's network. With just a few clicks, developers can set up a project and start building.

  2. Scalability: With nodes in over 14 regions and integrated load-balancing solutions, QuickNode RPC scales effortlessly with your dApp traffic.

  3. Free Tier: QuickNode offers a free, forever plan that lets anyone begin their development journey without upfront costs.

  4. Performance: QuickNode offers high-performance access to Hedera nodes, ensuring low-latency interactions and fast response times for your applications.

  5. Reliability: With QuickNode’s robust infrastructure, developers can rely on consistent uptime and availability, crucial for applications that require 24/7 operation.

  6. Comprehensive Web3 Tools: In addition to RPCs, QuickNode provides tools like Streams for setting up efficient blockchain data delivery systems without the need for custom ETL pipelines. Clusters offer an entire dedicated cluster of Hedera nodes, providing unmetered and isolated scalability. With Functions, you can create blockchain serverless functions in the cloud without hosting them on your infrastructure.

  7. Comprehensive Documentation and Support: QuickNode provides extensive documentation and dedicated support to help developers get the most out of their Hedera projects. Whether you’re facing technical challenges or need guidance on best practices, QuickNode’s team is there to assist you.

  8. Security: QuickNode prioritizes security, offering secure access to Hedera’s network with built-in features to protect your data and transactions.

By choosing QuickNode for your Hedera development, you can accelerate your development process and focus on building innovative solutions without worrying about infrastructure complexities.

Getting Started with Hedera on QuickNode

If you don't already have a QuickNode account, sign up at QuickNode. After creating your account, follow the steps to create a new Bitcoin endpoint.

  1. Access the Dashboard: After logging in, you’ll be directed to the QuickNode dashboard.

  2. Create an Endpoint:

    • Click on the "Create Endpoint" button.

      QuickNode

    • Select "Hedera" from the list of supported blockchains.

    • Select the network and click Continue

    • Name your endpoint and configure any additional settings as needed.

  3. Deploy the Endpoint: Once configuring your endpoint, click "Create Endpoint." QuickNode will take a few moments to deploy your Hedera RPC endpoint.

  4. Copy Endpoint URL: After deployment, you’ll be provided with an endpoint URL. Copy this URL as you’ll need it to connect to the Hedera network.

Developing with Hedera on QuickNode

QuickNode's support for Hedera allows developers to easily interact with the Hedera network using standard web technologies. Here's a step-by-step guide on using JavaScript to interact with the Hedera Mainnet via QuickNode's API.

Example: Fetching the Latest Block Number and Account Balance

This example demonstrates how to use the fetch API in JavaScript to make JSON-RPC calls to Hedera's Mainnet through QuickNode. We will retrieve the latest block number and get the balance of a specific account.

Prerequisites

To follow along with this example, you'll need:

  1. Node.js: Ensure that Node.js is installed on your machine. You can download it from nodejs.org.

  2. A Text Editor: Use a code editor like Visual Studio Code for writing and running your code.

  3. QuickNode Account: Set up a QuickNode account with a Hedera project to obtain your endpoint URL.

Installing Required Packages

Before running the code, you need to set up a Node.js environment and install the necessary packages:

  1. Create a New Project Directory: Open your terminal and create a new directory for your project. Navigate into it.

     mkdir hedera-quicknode-example
     cd hedera-quicknode-example
    
  2. Initialize a Node.js Project: Run the following command to create a package.json file:

     npm init -y
    
  3. Install Node-Fetch: You need to install node-fetch to use the fetch API in a Node.js environment. Run:

     npm install node-fetch
    
Writing the Code

Create a new JavaScript file in your project directory, for example, index.js, and paste the following code:

import fetch from 'node-fetch';

// Setting up headers for the request
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

// Request to fetch the latest block number
var rawBlockNumber = JSON.stringify({
  "method": "eth_blockNumber",
  "params": [],
  "id": 1,
  "jsonrpc": "2.0"
});

// Options for the fetch request
var requestOptionsBlock = {
  method: 'POST',
  headers: myHeaders,
  body: rawBlockNumber,
  redirect: 'follow'
};

// Fetching the latest block number from Hedera Mainnet
fetch("https://YOUR_QUICKNODE_STACKS_ENDPOINT/", requestOptionsBlock)
  .then(response => response.json())
  .then(result => {
    const blockNumberHex = result.result;
    const blockNumberDec = parseInt(blockNumberHex, 16);
    console.log("Latest Block Number:", blockNumberDec);
  })
  .catch(error => console.log('error', error));

// Request to get the balance of a specific account
var rawBalance = JSON.stringify({
  "method": "eth_getBalance",
  "params": [
    "0x00000000000000000000000000000000000003b1", // Example account address
    "latest"
  ],
  "id": 1,
  "jsonrpc": "2.0"
});

// Options for the fetch request
var requestOptionsBalance = {
  method: 'POST',
  headers: myHeaders,
  body: rawBalance,
  redirect: 'follow'
};

// Fetching the account balance from Hedera Mainnet
fetch("https://YOUR_QUICKNODE_STACKS_ENDPOINT/", requestOptionsBalance)
  .then(response => response.json())
  .then(result => {
    const balanceHex = result.result;
    const balanceDec = parseInt(balanceHex, 16);
    console.log("Account Balance:", balanceDec);
  })
  .catch(error => console.log('error', error));
Explanation
    1. import fetch from 'node-fetch';
      This line imports the fetch function from the node-fetch library, allowing you to make HTTP requests in a Node.js environment.

      1. var myHeaders = new Headers();
        This creates a new instance of the Headers object, which is used to configure HTTP headers for the requests.

      2. myHeaders.append("Content-Type", "application/json");
        This line appends a new header to the myHeaders object, setting the Content-Type to application/json. This indicates that the body of the request will be in JSON format.

      3. var rawBlockNumber = JSON.stringify({ ... });
        This line creates a JSON-RPC request object to fetch the latest block number. The object is then converted to a JSON string using JSON.stringify().

      4. method: "eth_blockNumber"
        This specifies the method name eth_blockNumber, which is used to retrieve the latest block number from the blockchain.

      5. params: []
        An empty array is provided as params since no parameters are needed for this method.

      6. id: 1
        This is an identifier for the request. It is used to match responses with requests in JSON-RPC.

      7. jsonrpc: "2.0"
        This specifies that the JSON-RPC version being used is 2.0.

      8. var requestOptionsBlock = { ... };
        This line defines an object called requestOptionsBlock that contains options for the HTTP request.

      9. method: 'POST'
        This sets the HTTP method to POST, which sends the request body to the server.

      10. headers: myHeaders
        This assigns the myHeaders object to the request options, ensuring the correct headers are sent.

      11. body: rawBlockNumber
        This specifies the request's body, which contains the JSON-RPC string for fetching the latest block number.

      12. redirect: 'follow'
        This option tells the request to follow any HTTP redirects automatically.

      13. fetch("https://.../", requestOptionsBlock)
        This line makes an HTTP request to the specified URL using the options defined in requestOptionsBlock.

      14. .then(response => response.json())
        This processes the HTTP response and parses it as JSON.

      15. .then(result => { ... })
        This callback function is executed after the JSON is parsed. It processes the result.

      16. const blockNumberHex = result.result;
        This line extracts the block number from the response in hexadecimal format.

      17. const blockNumberDec = parseInt(blockNumberHex, 16);
        This converts the block number from hexadecimal to a decimal integer.

      18. console.log("Latest Block Number:", blockNumberDec);
        This prints the latest block number in decimal format to the console.

      19. .catch(error => console.log('error', error));
        This handles any errors that occur during the fetch operation, logging them to the console.

      20. var rawBalance = JSON.stringify({ ... });
        This creates a JSON-RPC request object to fetch the balance of a specific account, converting it to a JSON string.

      21. method: "eth_getBalance"
        This specifies the method name eth_getBalance, which retrieves the balance of an account.

      22. params: [ "0x00000000000000000000000000000000000003b1", "latest" ]
        This provides the account address and the block parameter (latest) to get the current balance.

      23. var requestOptionsBalance = { ... };
        This line defines an object called requestOptionsBalance with options for the balance fetch request.

      24. fetch("https://.../", requestOptionsBalance)
        This line makes an HTTP request to fetch the account balance using the specified options.

      25. .then(response => response.json())
        This processes the balance fetch response and parses it as JSON.

      26. .then(result => { ... })
        This callback function is executed after parsing the JSON response to process the result.

      27. const balanceHex = result.result;
        This extracts the account balance from the response in hexadecimal format.

      28. const balanceDec = parseInt(balanceHex, 16);
        This converts the balance from hexadecimal to a decimal integer.

      29. console.log("Account Balance:", balanceDec);
        This prints the account balance in decimal format to the console.

      30. .catch(error => console.log('error', error));
        This handles any errors that occur during the fetch operation, logging them to the console.

Running the Code
  1. Run the Script: Execute the following command in your terminal to run the script:

     node index.js
    
  2. View the Output: The script will output the latest block number and the balance of the specified account in the console.

Using QuickNode’s Hedera support, developers can efficiently build, test, and deploy applications that interact with Hedera’s blockchain, leveraging its unique features for various use cases.

Conclusion

The integration of Hedera Mainnet and Testnet with QuickNode marks a significant milestone for developers. Hedera’s unique features combined with QuickNode’s reliable infrastructure provide a powerful platform for building scalable and secure applications. Whether you’re developing DeFi solutions, supply chain applications, or gaming platforms, QuickNode’s support for Hedera opens up new possibilities. Start exploring Hedera on QuickNode today and unlock the potential of this innovative technology.

I'd love to connect with you on Twitter | LinkedIn | Instagram.

Additional Resources

About QuickNode

QuickNode is dedicated to constructing the infrastructure necessary to uphold the forthcoming era of Web3. Since 2017, we've collaborated with numerous developers and organizations, facilitating the expansion of decentralized applications (dApps) and offering superior access to over 29 blockchains. Sign up for our newsletter to access further content similar to this and remain up-to-date with the latest developments in Web3!