Bsc RPC
How to use it
// yarn add @tatumio/tatum
import { TatumSDK, BinanceSmartChain, Network } from '@tatumio/tatum'
const tatum = await TatumSDK.init<BinanceSmartChain>({ network: Network.BINANCE_SMART_CHAIN })
const response = await tatum.rpc.getBlockTransactionCountByHash(
'0xd109a2054e3301c446573859bcbdb0fb26107ea1c218d097042b34e3bd8f6d91',
)
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs
Overview
eth_getBlockTransactionCountByHash
is a 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
:"0xd109a2054e3301c446573859bcbdb0fb26107ea1c218d097042b34e3bd8f6d91"
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": ["0xd109a2054e3301c446573859bcbdb0fb26107ea1c218d097042b34e3bd8f6d91"]
}
JSON-RPC response
{
"id": 1,
"jsonrpc": "2.0",
"result": "0x147"
}
In this example, the block with the hash "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"
has a total of 10 transactions (indicated by the hexadecimal value "0xa"
).