Skip to main content

How to Use QuickNode Single Flight RPC

Updated on
Aug 18, 2023

4 min read

Overview

Blockchain networks are like mines, dark and complex, and the data on these chains is like gold. Much work must be done to extract gold from mines, similar to extracting data from a blockchain network consisting of various processes. Block data and transaction receipts are crucial pieces of this data as they maintain the transparency and integrity of the network. Blocks contain all the transactions that have been processed by the network and are linked together through the use of unique hashes. Transaction receipts provide proof that a particular transaction has been processed and allow users to track the progress of their transactions through the Ethereum network. Together, blocks and transaction receipts help ensure the security and reliability of the Ethereum network. In this guide, we will talk about a QuickNode Marketplace add-on Single flight RPC which makes the task of getting these data sets easier.

What You Will Need

What You Will Do

  • Learn about the current processes of getting block and transaction data from Ethereum.
  • Learn how to get the same data easier using the Single Flight RPC add-on from the QuickNode Marketplace.

What is Backfilling?

Backfilling is the process of pulling all data from the genesis to tip for blockchain and then indexing the data on an off-chain database. This eventually decreases the number of calls or interactions with blockchain every time data is required because querying blockchain is expensive and time-consuming. Having all the data available on an off-chain database reduces the number of calls to blockchains, which can be expensive and time-consuming.

What does this process look like today?

Today, this process involves making a block or transaction-level method call to blockchain nodes to get the necessary information. This results in the following inefficiencies:

Time - Organizations and developers can spend months gathering the information needed to start their initiative.

Engineering - Once organizations have the required data, it can take months to develop the systems needed to post-process these large amounts of data.

Cost - Depending on the chain - getting transaction details can cost hundreds of thousands of dollars.

What is the QuickNode Marketplace?

QuickNode's Marketplace is a platform where developers and companies can list their web3 tools, which can work alongside QuickNode's core RPC. It's like an app store for web3 tools. Learn how to create and showcase your own tools.

Creating an Ethereum Endpoint with QuickNode

To use the Single Flight RPC, we'd first need to install the add-on on the 'Configure add-ons' page while creating our QuickNode endpoint.

Retrieving Block & Transaction Data

In this guide, we'll see how we can easily get block and transaction data using the Single Flight RPC add-on on the QuickNode Marketplace. But first, let's see how we traditionally get block and transaction data.

Traditional way - Using a QuickNode endpoint without the Single Flight RPC add-on.

To get block data on Ethereum or some other EVM-based chains, we use the method eth_getBlockByNumber or eth_getBlockByHash.

curl QUICKNODE_HTTPS_URL_HERE \
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"eth_getBlockByNumber","params":["0xc5043f",false],"id":1,"jsonrpc":"2.0"}'
curl QUICKNODE_HTTPS_URL_HERE \
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"eth_getBlockByHash","params":["0x829df9bb801fc0494abf2f443423a49ffa32964554db71b098d332d87b70a48b",false],"id":1,"jsonrpc":"2.0"}'

To get the transaction data we'd have to call eth_getTransactionReceipt for each transaction hash we get in the block data using eth_getBlockByNumber/eth_getBlockByHash method.

curl QUICKNODE_URL_HERE
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"eth_getTransactionReceipt","params":["0x04b713fdbbf14d4712df5ccc7bb3dfb102ac28b99872506a363c0dcc0ce4343c"],"id":1,"jsonrpc":"2.0"}'

Quick way - Using a QuickNode endpoint with the Single Flight RPC add-on.

We can go through the lengthy process of getting transaction and block data which we saw in the last section, or we can use the Single Flight RPC add-on from the QuickNode Marketplace. Let's see the add-on in action:

  • qn_getBlockWithReceipts: This RPC method will give you all transaction receipts along with the block data for the queried block.
curl QUICKNODE_URL_HERE
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"qn_getBlockWithReceipts","params":["0xEDA8CE"],"id":1,"jsonrpc":"2.0"}'
  • qn_getReciepts: This RPC method will give you all transaction receipts for the queried block.
curl QUICKNODE_URL_HERE
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"qn_getReceipts","params":["0xEDA8CE"],"id":1,"jsonrpc":"2.0"}'

Single Flight RPC is supported on the following chains:

Note: All the QuickNode custom methods come with a retry capability so that a response to a request is always guaranteed.

Takeaways

This guide taught us an efficient way to get block and transaction data using the Single Flight RPC add-on from the QuickNode Marketplace. Join our Discord if you have any questions, or reach out to us via Twitter.

We ❤️ Feedback!

If you have any feedback or questions on this guide, let us know. We'd love to hear from you!

Share this guide