eth_getTransactionByHash | Fantom

Fantom API method that returns information about a transaction from its hash. It is used to retrieve information about a specific transaction by its hash. The method returns an object with details about the transaction, such as the sender, recipient, gas used, transaction value, and more.

πŸ‘

Get you own node endpoint today

Start for free and get your app to production levels immediately. No credit card required.

You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • hash β€” the hash identifying a transaction

Response

  • object β€” the transaction response object, or null if no transaction is found:
    • blockHash β€” the block hash. Identifies the block in which the transaction was included. This field is null for transactions that have not yet been included in a block.
    • blockNumber β€” the number of the block in which the transaction was included. This field is null for transactions that have not yet been included in a block.
    • from β€” the address of the sender who initiated the transaction.
    • gas β€” the units of gas included in the transaction by the sender.
    • gasPrice β€” the price of gas in Wei included in the transaction by the sender.
    • maxFeePerGas β€” the maximum amount the transaction's sender is willing to pay per unit of gas for the transaction to be executed.
    • maxPriorityFeePerGas β€” the maximum priority fee the transaction sender is willing to pay per gas unit.
    • hash β€” the hash that uniquely identifies the transaction.
    • input β€” the optional input data sent with the transaction., usually used to interact with smart contracts.
    • nonce β€” a counter identifying the transaction's number sent by the sender wallet; it essentially identifies how many transactions an account has made. It is used to ensure each transaction is executed only once.
    • to β€” the recipient's address of the transaction if it was a transaction to an address. For contract creation transactions, this field is null.
    • transactionIndex β€” the index of the transaction within the block. This field is null for transactions that have not yet been included in a block.
    • value β€” the value of the native token transferred along with the transaction in Wei.
    • type β€” the type of the transaction. 0 indicates a regular transfer; 2 indicates a contract creation or smart contract function call.
    • accessList β€” a list of authorized addresses and storage keys the transaction plans to interact with.
    • v β€” the recovery parameter in the Ethereum Signature Algorithm (ECDSA).
    • r β€” the first component of the signature in the Ethereum Signature Algorithm (ECDSA).
    • s β€” the second component of the signature in the Ethereum Signature Algorithm (ECDSA).

eth_getTransactionByHash code examples

const { Web3 } = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);

async function getTransaction(transactionHash) {
 const transaction = await web3.eth.getTransaction(transactionHash)
 console.log(transaction)
}

getTransaction("0x658d83eb9395221ffb8c2bf3696b88f61262527b145bd7ffdb7310edb8886e3b")
const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);

const getTransaction = async (transactionHash) => {
    const transaction = await provider.send("eth_getTransactionByHash", [transactionHash]);
    console.log(transaction);
  };

getTransaction("0x658d83eb9395221ffb8c2bf3696b88f61262527b145bd7ffdb7310edb8886e3b")
from web3 import Web3  
node_url = "CHAINSTACK_NODE_URL" 

web3 = Web3(Web3.HTTPProvider(node_url)) 
print(web3.eth.get_transaction("0x658d83eb9395221ffb8c2bf3696b88f61262527b145bd7ffdb7310edb8886e3b")) 

Use case

One use case for eth_getTransactionByHash is to inspect a specific transaction and display information about it, such as the address sent, the block it was included in, and the number of transactions the sender sent so far (nonce). This information can be useful for monitoring and analyzing transactions.

Try the eth_getTransactionByHash RPC method yourself

Language
Click Try It! to start a request and see the response here!