eth_getTransactionByBlockNumberAndIndex - Optimism
Example code for the eth_getTransactionByBlockNumberAndIndex json-rpc method. Сomplete guide on how to use eth_getTransactionByBlockNumberAndIndex json-rpc in GetBlock.io Web3 documentation.
Parameters
Parameter
Type
Description
Required
Request Sample
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByBlockNumberAndIndex",
"params": ["0x7A69B2C", "0x0"],
"id": "getblock.io"
}'const axios = require('axios');
const url = "https://go.getblock.io/<ACCESS-TOKEN>/";
const headers = { "Content-Type": "application/json" };
const payload = {
jsonrpc: "2.0",
method: "eth_getTransactionByBlockNumberAndIndex",
params: ["0x7A69B2C", "0x0"],
id: "getblock.io"
};
axios.post(url, payload, { headers })
.then(response => {
if (response.status === 200) {
console.log("eth_getTransactionByBlockNumberAndIndex result:", response.data.result);
} else {
console.error("Error:", response.status, response.statusText);
}
})
.catch(error => {
console.error("Error:", error.response ? error.response.data : error.message);
});Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": {
"blockHash": "0x1ff2fcd80ed93d75855364f7e879795dbd5790210c5224ad2c1083d9744297d6",
"blockNumber": "0x7a69b2c",
"blockTimestamp": "0x67411011",
"from": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001",
"gas": "0xf4240",
"gasPrice": "0x0",
"hash": "0x4fae8f6c70a4f50cf8894bf9847ed364922826658c3cb73e291e03934637a853",
"input": "0x440a5e200000146b000f79c500000000000000040000000067410f83000000000144320300000000000000000000000000000000000000000000000000000002fe2cca3c00000000000000000000000000000000000000000000000000000000001f11bf37aac56bf514562b0ee38600119c0a4f70b20f0c6abc66a2011d1bdd9b18cb1c0000000000000000000000006887246668a3b87f54deb3b94ba47a6f63f32985",
"nonce": "0x160d8b6",
"to": "0x4200000000000000000000000000000000000015",
"transactionIndex": "0x0",
"value": "0x0",
"type": "0x7e",
"v": "0x0",
"r": "0x0",
"s": "0x0",
"sourceHash": "0xf14ecb423df1f95f609d9781126cdd9ea4d248f4502c083507b2f1f72aa779a8",
"mint": "0x0",
"depositReceiptVersion": "0x1"
}
}
Response Parameters
Use Case
Error handling
Status Code
Error Message
Cause
Integration with Web3
Last updated
Was this helpful?