eth_getTransactionByHash

Ethereum RPC

Overview

The eth_getTransactionByHash is an Ethereum JSON-RPC method that allows you to query transaction details based on its hash. This method is useful when you want to retrieve information about a specific transaction, such as its sender, receiver, value, and more. Common use cases include tracking transaction status, monitoring incoming transactions, or analyzing historical transaction data.

Parameters

The eth_getTransactionByHash method takes one parameter:

  • transactionHash: The hash of the transaction you want to retrieve. This should be a 32-byte hash string with a 0x prefix.
    • Example: 0x97696c2014695e851d85a344cbbc6ae8ab9d386de05cb0230fe50b91c044639b

Returns

The method returns a JSON object containing the following fields:

NameDescription
hashThe transaction hash as a 32-byte hex string.
nonceThe number of transactions made by the sender prior to this one.
blockHashThe hash of the block in which this transaction is included.
blockNumberThe block number in which this transaction is included.
transactionIndexThe index of the transaction within the block.
fromThe address of the sender.
toThe address of the recipient. null if the transaction is a contract creation transaction.
valueThe value transferred in wei.
gasPriceThe gas price provided by the sender in wei.
gasThe gas limit provided by the sender.
inputThe data sent along with the transaction.

Request

curl --location 'https://api.tatum.io/v3/blockchain/node/ethereum-mainnet/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
  "jsonrpc": "2.0",
  "method": "eth_getTransactionByHash",
  "params": ["0x97696c2014695e851d85a344cbbc6ae8ab9d386de05cb0230fe50b91c044639b"],
  "id": 1
}'

// yarn add @tatumio/tatum

import { TatumSDK, Ethereum, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })

const tx = await tatum.rpc.getTransactionByHash(
  '0x97696c2014695e851d85a344cbbc6ae8ab9d386de05cb0230fe50b91c044639b',
)

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs