eth_getTransactionByBlockHashAndIndex
Returns information about a transaction given block hash and transaction index position.
Parameters
block hash
: [Required] A string representing the hash (32 bytes) of a block.transaction index position
: [Required] A hexadecimal of the integer representing the position in the block.
Returns
A transaction object, or null when no transaction was found. The transaction object will consist of the following keys and their values:
accessList
: [optional] A list of addresses and storage keys accessed by the transaction. See access list transactions.blockHash
: 32 bytes. A hash of the block including this transaction.null
when it's pending.blockNumber
: The number of the block including this transaction.null
when it's pending.chainID
: [optional] chain ID specifying the network. Returned only for EIP-1559 transactions.from
: 20 bytes. The address of the sender.gas
: Gas provided by the sender.gasPrice
: Gas price provided by the sender in Wei.hash
: 32 bytes. The hash of the transaction.input
: The data sent along with the transaction.maxPriorityFeePerGas
: [optional] Maximum fee, in Wei, the sender is willing to pay per gas above the base fee. See EIP-1559 transactions.maxFeePerGas
: [optional] Maximum total fee (base fee + priority fee), in Wei, the sender is willing to pay per gas. See EIP-1559 transactions.nonce
: The number of transactions made by the sender prior to this one.r
: 32 bytes. The ECDSA signaturer
.s
: 32 bytes. The ECDSA signatures
.to
: 20 bytes. The address of the receiver.null
when it's a contract creation transaction.transactionIndex
: The transaction's index position in the block, in hexadecimal.null
when it's pending.type
: The transaction type.v
: The ECDSA recovery ID.value
: The value transferred in Wei.yParity
: [optional] Parity (0x0
for even,0x1
for odd) of the y-value of asecp256k1
signature.
Example
Replace YOUR-API-KEY
with an API key from your Infura dashboard.
Request
- cURL
- WSS
curl https://mainnet.infura.io/v3/YOUR-API-KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockHashAndIndex","params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35","0x0"],"id":1}'
wscat -c wss://mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockHashAndIndex","params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35","0x0"],"id":1}'
Response
- JSON
{
"id" : 1,
"jsonrpc" : "2.0",
"result":{
"accessList":[],
"blockHash":"0xfdc2fb4ce6356fef28fda948d675182d5759d0c885ec9a4b7fff604a8167a118",
"blockNumber":"0x11dd3de",
"chainId":"0x1",
"from":"0x1f9090aae28b8a3dceadf281b0f12828e676c326","gas":"0x565f","gasPrice":"0x6f4d3132b",
"hash":"0x24ea08c3b1bc777a23d0373dd3f8a980455c7817d814c5f34df5a3e3caf5c9a1",
"input":"0x",
"maxFeePerGas":"0x6f4d3132b",
"maxPriorityFeePerGas":"0x0",
"nonce":"0x63dbc",
"r":"0xd38fcf50bab3898938058cd0337e655d0fdc302b57807da83f59b27035055ed5",
"s":"0x300ae498fe06a5fa65ebb69fc2bd99a3fbbf991543ff3dce2c45c3b43c5113fd",
"to":"0x388c818ca8b9251b393131c08a736a67ccb19297",
"transactionIndex":"0xa2",
"type":"0x2",
"v":"0x1",
"value":"0x2e463634a25a9a2",
"yParity":"0x1"
}
}