eth_getTransactionByHash - Optimism
Example code for the eth_getTransactionByHash json-rpc method. Сomplete guide on how to use eth_getTransactionByHash json-rpc in GetBlock.io Web3 documentation.
Parameters
Parameter
Type
Description
Required
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685"],
"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_getTransactionByHash",
params: ["0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685"],
id: "getblock.io"
};
axios.post(url, payload, { headers })
.then(response => {
if (response.status === 200) {
console.log("eth_getTransactionByHash 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": "0x3e4a6a9efc7e4db75269430a5683ae3c7505ab0848d7814bd1c73c76e6882467",
"blockNumber": "0x9087826",
"blockTimestamp": "0x6a04ca05",
"from": "0xcde377407d9b819efc0e185aa2d442194c2233e6",
"gas": "0x27ac40",
"gasPrice": "0x15f",
"maxFeePerGas": "0x5f5e100",
"maxPriorityFeePerGas": "0x1",
"hash": "0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685",
"input": "0x83730cc30000000000000000000000000000000000000000000000000000000009087826",
"nonce": "0xb1ebba",
"to": "0x4aed348173bbf17dfaeb91598321904c9323d36e",
"transactionIndex": "0x23",
"value": "0x0",
"type": "0x2",
"accessList": [],
"chainId": "0xa",
"v": "0x1",
"r": "0x4d68c5f11ba8c7803a3abe897b9ba8956e0938bf9338e2467ebc0b10996b85cd",
"s": "0x5e76ac945fa081a13869c9f3adb9f5484b0b89f074322ec5015ef913b0bb6e0a",
"yParity": "0x1"
}
}
Response Parameters
Field
Type
Description
Use Case
Error handling
Status Code
Error Message
Cause
Integration with Web3
Last updated
Was this helpful?