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_getTransactionByBlockNumberAndIndex

Get Transaction By Block Number And Index​

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

Retrieves a specific transaction by its block number (which can be specified as a hexadecimal or as one of the special strings 'latest', 'earliest', 'pending') and its index position within the block.

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 number 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_getTransactionByBlockNumberAndIndex"
})
};

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"
}