eth_getTransactionByBlockHashAndIndex - BSC
Example code for the eth_getTransactionByBlockHashAndIndex JSON RPC method. Сomplete guide on how to use eth_getTransactionByBlockHashAndIndex JSON RPC in GetBlock Web3 documentation.
This method returns information about a transaction by block hash and transaction index position on the BNB Smart Chain.
Parameters
blockHash
string
Yes
32-byte block hash
index
string
Yes
Transaction index (hex)
Request Example
curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByBlockHashAndIndex",
"params": [
"0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd",
"0x0"
],
"id": "getblock.io"
}'const axios = require('axios');
const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';
const payload = {
jsonrpc: '2.0',
method: 'eth_getTransactionByBlockHashAndIndex',
params: [
'0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd',
'0x0'
],
id: 'getblock.io'
};
axios.post(url, payload, {
headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));Response Example
Response Parameters Definition
hash
string
Hash of the transaction
blockHash
string
Hash of the block this transaction belongs to
blockNumber
string (hex)
Block number
from
string
Sender address
to
string or null
Receiver address or null for contract creation
value
string (hex)
Value transferred in wei
nonce
string (hex)
Number of transactions previously sent by the sender
gas
string (hex)
Gas limit
gasPrice
string (hex)
Gas price in wei
input
string (hex)
Transaction calldata
transactionIndex
string (hex)
Index of the transaction inside the block
v, r, s
string
ECDSA signature values
Use Cases
Iterate through block transactions
Build block explorers
Analyze transaction ordering
Error Handling
-32602
Invalid params
null result
Transaction not found
SDK Integration
Last updated
Was this helpful?