For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

This method retrieves comprehensive transaction data, including the sender, recipient, value, gas parameters, input data, and block information. It's one of the most commonly used methods for tracking transaction status and retrieving transaction details. The method returns null if the transaction is not found. On Optimism, the transaction object may include additional L2-specific fields.

Parameters

Parameter
Type
Description
Required

transactionHash

DATA, 32 Bytes

The hash of a transaction.

Yes

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

Response

A successful response returns the following:

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

hash

string

Hash of the transaction

blockHash

string or null

Hash of the block that contains this transaction. Null if pending

blockNumber

string or null

Block number in hex. Null if pending

transactionIndex

string or null

Index of this transaction in the block

from

string

Sender address

to

string or null

Receiver address. Null for contract creation

value

string (hex)

Amount sent in wei

nonce

string (hex)

Counter of transactions sent by the sender

gas

string (hex)

Gas limit for the transaction

gasPrice

string (hex)

Gas price in wei

input

string (hex)

Calldata or contract code

v, r, s

string

Transaction signature components

Use Case

The eth_getTransactionByHash method is commonly used for:

  • Transaction tracking

  • Payment verification

  • Debugging transactions

  • Transaction history display

Error handling

Status Code
Error Message
Cause

404

Not Found

Missing or invalid ACCESS_TOKEN.

-32602

Invalid argument

  • Transaction hash is invalid

Integration with Web3

The eth_getTransactionByHash method helps developers to:

  • Build trustless frontends that check transaction status directly

  • Track pending, failed, or confirmed transactions in real time

  • Support dashboards, DeFi interfaces, wallets, and explorers

  • Read transaction calldata for analytics and debugging

  • Improve UX by notifying users instantly when their transaction is included

  • Verify transaction ordering for MEV, priority fees, and gas bidding strategies

Last updated

Was this helpful?