eth_getTransactionByHash - Ethereum

Retrieve transaction details by transaction hash using eth_getTransactionByHash. Essential for tracking and verifying individual transactions on the Ethereum blockchain.

The Ethereum eth_getTransactionByHash method is part of the Ethereum JSON RPC Core API, used to interact with Ethereum nodes. The eth_getTransactionByHash RPC Ethereum method is crucial for tracking and verifying individual transactions.

Supported Networks

The eth_getTransactionByHash RPC Ethereum method supports the following network types:

  • Mainnet

  • Testnet: Sepolia, Hoodi

Parameters

  • DATA: The 32-byte hash transaction.

Request

URL

https://go.getblock.io/<ACCESS-TOKEN>/

To make a request, send a JSON object with the jsonrpc, method, and params fields. Below is an example of how to make a request using curl:

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getTransactionByHash",
    "params": [
        "0xcd718a69d478340dc28fdf6bf8056374a52dc95841b44083163ced8dfe29310c"
    ],
    "id": "getblock.io"
}'

Response

The server responds with a JSON object containing the transaction details for the specified hash. Below is an example of a typical response:

Response Description

  • accessList: A list of addresses and storage keys the transaction accesses (EIP-2930).

  • blockHash: The hash of the block containing the transaction.

  • blockNumber: The number of the block containing the transaction.

  • chainId: The chain ID of the Ethereum network.

  • from: The address of the sender.

  • gas: The gas provided by the sender.

  • gasPrice: The gas price provided by the sender in Wei.

  • hash: The hash of the transaction.

  • input: The input data for the transaction.

  • maxFeePerGas: Maximum fee per gas that the sender is willing to pay.

  • maxPriorityFeePerGas: Maximum priority fee per gas.

  • nonce: The number of transactions made by the sender prior to this one.

  • r, s, v: Components of the transaction signature.

  • to: The address of the receiver.

  • transactionIndex: The index position of the transaction within the block.

  • type: The transaction type.

  • value: The value transferred in Wei.

Use Case

The eth_getTransactionByHash method is particularly useful for retrieving detailed information about a specific transaction, which can be critical for verifying and tracking transactions on the Ethereum blockchain. In case of an eth_getTransactionByHash error, developers should verify that the provided transaction hash is correct and corresponds to an existing transaction. An eth_getTransactionByHash example can help developers understand the correct usage of this method.

Code Example

You can also make requests to the eth_getTransactionByHash method programmatically using Python. Below is an example using the requests library:

This Python script sends a request to the eth_getTransactionByHash method and prints the returned transaction information. Make sure to replace <ACCESS-TOKEN> with your actual API token. This script serves as an eth_getTransactionByHash example for developers to understand the implementation in Python.

The Web3 eth_getTransactionByHash method can also be used in Web3 libraries for Ethereum, providing an interface to access detailed transaction data based on a specific transaction hash.

Last updated

Was this helpful?