eth_getBlockTransactionCountByHash - Base
Example code for the eth_getBlockTransactionCountByHash JSON-RPC method. Complete guide on how to use eth_getBlockTransactionCountByHash JSON-RPC in GetBlock Web3 documentation.
Parameters
Parameter
Type
Required
Description
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByHash",
"params": ["0x849a3ac8f0d81df1a645701cdb9f90e58500d2eabb80ff3b7f4e8c13f025eff2"],
"id": "getblock.io"
}'const axios = require('axios');
const blockHash = '0x849a3ac8f0d81df1a645701cdb9f90e58500d2eabb80ff3b7f4e8c13f025eff2';
const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
jsonrpc: '2.0',
method: 'eth_getBlockTransactionCountByHash',
params: [blockHash],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
const txCount = parseInt(response.data.result, 16);
console.log('Transaction Count:', txCount);Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "0x8"
}Response Parameters
Parameter
Type
Description
Use Cases
Error Handling
Error Code
Message
Description
Web3 Integration
Last updated
Was this helpful?