# eth\_getTransactionByHash - TRON

## Description

The eth\_getTransactionByHash Web3 method in the Tron protocol allows users to fetch detailed information about a specific transaction using its hash. This method, part of the eth\_getTransactionByHash RPC protocol, provides essential transaction data such as block number, timestamp, sender and receiver addresses, and transaction value. By calling this method through the JSON-RPC API Interface, developers can seamlessly integrate transaction retrieval capabilities into their applications, enhancing blockchain interaction and data analysis. This function is crucial for verifying transaction statuses, auditing blockchain activity, and developing decentralized applications (dApps) that require real-time transaction insights.

## Supported Networks

The eth\_getTransactionByHash RPC method supports the following network types

* **Mainnet**
* **Testnets**

## Parameters

Here is the list of parameters the eth\_getTransactionByHash method needs to be executed.

* **Parameter**: Transaction Hash
  * **Required/Optional**: Required
  * **Type**: String
  * **Description**: The hash of the transaction that you want to retrieve information about.
  * **Default/Supported Values**: A 32-byte hash value represented as a hexadecimal string prefixed with "0x".

### URL

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

Here’s a sample cURL request using eth\_getTransactionByHash

Request

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

Response

```json

{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": null
}
```

## Body Parameters

Here is the list of body parameters for the `eth_getTransactionByHash` method:

1. **jsonrpc**: A string specifying the version of the JSON-RPC protocol, which is "2.0" for this method.
2. **id**: A unique identifier for the request. It can be a string or a number and is used to match the response with the request. In the example, it is "getblock.io".
3. **result**: This is the main body parameter in the response, which contains the transaction object if the transaction is found. If the transaction is not found, this will be `null`. The transaction object includes several fields such as:
   * **hash**: The transaction hash.
   * **nonce**: The number of transactions made by the sender prior to this one.
   * **blockHash**: The hash of the block where this transaction was included. `null` when the transaction is pending.
   * **blockNumber**: The block number where this transaction was included. `null` when the transaction is pending.
   * **transactionIndex**: The transaction's index position in the block. `null` when the transaction is pending.
   * **from**: The address of the sender.
   * **to**: The address of the receiver. `null` when it is a contract creation transaction.
   * **value**: The value transferred in Wei.
   * **gas**: The gas provided by the sender.
   * **gasPrice**: The gas price provided by the sender in Wei.
   * **input**: The data sent along with the transaction.
   * **v, r, s**: Components of the transaction's signature.

## Use Case

Here are some use-cases for the `eth_getTransactionByHash` method:

1. **Transaction Verification and Tracking**: One of the primary use cases for the `eth_getTransactionByHash` method is to verify the status and details of a particular transaction on the Ethereum blockchain. Developers and users can use this method to retrieve information such as the transaction's sender and receiver addresses, the amount of Ether transferred, gas used, and the transaction's confirmation status. This is particularly useful for applications that need to track the progress of transactions, such as wallets or exchanges, ensuring that transactions have been successfully processed and confirmed.
2. **Debugging and Error Handling**: For developers building decentralized applications (dApps), the `eth_getTransactionByHash` method can be an essential tool for debugging and error handling. By retrieving the transaction details, developers can analyze failed transactions to understand what went wrong, such as insufficient gas, incorrect data payloads, or nonce issues. This information can then be used to fix bugs and improve the reliability of dApps.
3. **Auditing and Compliance**: In scenarios where auditing and compliance are critical, such as in financial services or regulated industries, the `eth_getTransactionByHash` method can be used to provide a detailed audit trail of transactions. By accessing transaction details, organizations can ensure compliance with regulations, verify transaction authenticity, and maintain records for auditing purposes. This can help in building trust and transparency with clients and regulatory bodies.

## Code for eth\_getTransactionByHash

```python
import requests
import json

url = "https://go.getblock.io/<ACCESS-TOKEN>/"
headers = {
    "Content-Type": "application/json"
}
payload = {"jsonrpc": "2.0", "method": "eth_getTransactionByHash", "params": ["c9af231ad59bcd7e8dcf827afd45020a02112704dce74ec5f72cb090aa07eef0"], "id": "getblock.io"}

response = requests.post(url, headers=headers, data=json.dumps(payload))

# Check the response and print the result
if response.status_code == 200:
    print("Result:", response.json().get("result"))
else:
    print("Error:", response.status_code, response.text)
```

## Common Errors

Common Errors\
When using the eth\_getTransactionByHash RPC Tron method, the following issues may occur:

* **Invalid Transaction Hash**: If the transaction hash is malformed or incorrect, the method will return a null result. Ensure the hash is a valid 32-byte hexadecimal string without any prefixes or suffixes.
* **Transaction Not Found**: If the transaction is not yet mined or does not exist on the blockchain, the method may return null. Verify that the transaction hash corresponds to a confirmed transaction and check the network status for pending transactions.
* **Network Connectivity Issues**: Poor connectivity to the Tron network could lead to timeouts or incomplete responses. Ensure your network connection is stable and consider increasing the timeout settings for your RPC client.
* **Node Configuration Error**: If the node is not configured correctly or is out of sync, it may return inaccurate data. Regularly update and maintain your node to ensure it is fully synced with the network.

Using the eth\_getTransactionByHash method in Web3 applications provides a reliable means to retrieve detailed information about specific transactions, enabling developers to track transaction statuses and verify their execution. This functionality is crucial for building responsive and transparent blockchain applications, enhancing user trust and interaction efficiency.

### conclusion

The `eth_getTransactionByHash` RPC method is an Ethereum-specific API call used to retrieve detailed information about a transaction using its hash. Unlike Ethereum, Tron has its own set of methods for interacting with transactions on its blockchain. Understanding the differences between Ethereum's `eth_getTransactionByHash` and Tron's RPC methods is crucial for developers working across multiple blockchain platforms.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.getblock.io/api-reference/tron-trx/json-rpc_api/eth_gettransactionbyhash.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
