Skip to main content

Don't have an RPC Node yet?

Start using RPC Nodes in your project today.

Get your free RPC Node
Version: 2.2

eth_getTransactionByBlockHashAndIndex

Get Transaction By Hash And Index​

POSThttps://site1.moralis-nodes.com/:chain/:apiKey

Retrieves a single transaction by its block hash and index position within the block. This allows for precise querying of transactions when the block hash and transaction's index are known.

Note

Please refer to RPC schema page for more details on the RPC params and RPC response definitions of the RPC method.

PATH PARAMS
chainstringrequired
The blockchain to interact with.
apiKeystringrequired
Your API key for authentication.
BODY PARAM
jsonrpcstringrequired
JSON-RPC version (typically 2.0).
idnumberrequired
The request identifier.
methodstringrequired
The JSON-RPC method being invoked.
paramsrpcArrayrequired
Parameters for the method, including the block hash and the transaction index.
Responses
// Dependencies to install:
// $ npm install node-fetch --save
// add "type": "module" to package.json

import fetch from 'node-fetch';

const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json'
},
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getTransactionByBlockHashAndIndex"
})
};

fetch('https://site1.moralis-nodes.com/eth/YOUR_API_KEY', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
Response Example
{
"blockHash": "0x18173058d45f8aa984181fdfbfece01a93a971ea63e008231b2e15f151e0903f",
"blockNumber": "0x12b39a9",
"from": "0xbb936e46099df268a2c6537299b75cf3609a0541",
"gas": "0x2bace",
"gasPrice": "0x3bb9d4fcb",
"maxPriorityFeePerGas": "0x4c4b40",
"maxFeePerGas": "0x5666e04ce",
"hash": "0x6e760d4b659e9c68b943829b0f4adaa07f3e3c043ee8d4f4787045909ba63090",
"input": "0xa76dfc3b...",
"nonce": "0x1b00",
"to": "0x111111125421ca6dc452d289314280a0f8842a65",
"transactionIndex": "0x0",
"value": "0x214e8348c4f0000",
"type": "0x2",
"chainId": "0x1",
"v": "0x1",
"r": "0xf611431e6b44cbc02c4278915d979c9034b6d37b139b8c55ae428abbe9d52d4b",
"s": "0x1bc0fcf547e60d54daf313f840db039c3c1904c5b9724b9d7a8ec1f2abb46b53"
}