eth_getTransactionByBlockHashAndIndex
Returns information about a transaction by block hash and transaction index position.
Parameters
DATA
, 32 Bytes - hash of a block.QUANTITY
- integer of the transaction index position.
Returns
Example
NOTE: In this example we are using public Ethereum endpoint. Ideally, for your own projects, you should use your own endpoint, which you can generate for free by connecting to your wallet here.
Query
NOTE: ethers
used below is a well-known web3 library, check it out here.
import { ethers } from 'ethers';
const provider =
new ethers
.providers
.JsonRpcProvider("https://www.noderpc.xyz/rpc-mainnet/public")
provider.send('eth_getTransactionByBlockHashAndIndex', ["0x829df9bb801fc0494abf2f443423a49ffa32964554db71b098d332d87b70a48b", "0x0"]).then((tx) => {
console.log(tx);
});
Result
{
"blockHash": "0x829df9bb801fc0494abf2f443423a49ffa32964554db71b098d332d87b70a48b",
"blockNumber": "0xc4fa88",
"from": "0xf410114a4320680ede1dcd360e40f038396255ab",
"gas": "0x124f80",
"gasPrice": "0x1",
"hash": "0x1d9f631e6ac0b8940b65ea064a073e63324c60ccea1880dc9dd39a279276e7d1",
"input": "0x1cff79cd000000000000000000000000957bc1d2ef326c03dc991418ae7afb4985e7fab2000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a499037ebb00000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000056178a0d5f301baf6cf3e1cd53d9863437345bf9000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000a2a15d09519be00000000000000000000000000000000000000000000000c23a1327492d955677a8000000000000000000000000000000000000000000000000001f46d6f25e6ad000000000000000000000000000000000000000524dafe38c2aa62b7a3175677f000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000061003622000000000000000000000000000000000000000000000000000000000000003f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000",
"nonce": "0x13d9",
"to": "0xa57bd00134b2850b2a1c55860c9e9ea100fdd6cf",
"transactionIndex": "0x0",
"value": "0x0",
"type": "0x0",
"chainId": "0x1",
"v": "0x25",
"r": "0xcf22c0fbcf67e9c7c0836feec720c8604b3cde387d2394dc9b52396afe4766c6",
"s": "0x1b3da5eb34c772c6fba28d6890d515c5cb761388c00830a5868c333257df6b2c"
}
Last updated