eth_getBlockTransactionCountByHash

How to use it

// yarn add @tatumio/tatum

import { TatumSDK, XinFin, Network } from '@tatumio/tatum'
  
const tatum = await TatumSDK.init<XinFin>({ network: Network.XINFIN })

const response = await tatum.rpc.getBlockTransactionCountByHash('0x0003bd8d00000625538ae9cb302a2eea2f17e5b751b447257b94617d90f1e01c')

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

eth_getBlockTransactionCountByHash is an RPC method used to fetch the number of transactions in a block by the block's hash. It is useful when you want to know the total number of transactions included in a specific block and don't want to retrieve the entire block data. This method can be used in various scenarios, such as monitoring the network activity or estimating transaction confirmation times.

Parameters

This method requires a single parameter:

  • blockHash: The hash of the target block for which the transaction count will be retrieved. It should be a valid 32-byte hex string.

Example of the parameter:

  • blockHash: "0x0003bd8d00000625538ae9cb302a2eea2f17e5b751b447257b94617d90f1e01c"

Return

The method returns a single value:

  • transactionCount: The total number of transactions included in the specified block. It is returned as a hexadecimal value.

Examples

JSON-RPC request

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_getBlockTransactionCountByHash",
  "params": [
    "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"
  ]
}

JSON-RPC response

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": "0xa"
}

In this example, the block with the hash "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238" has a total of 10 transactions (indicated by the hexadecimal value "0xa").

Last updated

ยฉ Tatum Technology, LLC