> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.chainstack.com/feedback

```json
{
  "path": "/reference/avalanche-gettransactionbyhash",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# eth_getTransactionByHash | Avalanche

Avalanche API method that returns the information about a transaction from the transaction 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.

<Check>
  **Get your own node endpoint today**

  [Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required.

  You can sign up with your GitHub, X, Google, or Microsoft account.
</Check>

## 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 sender of the transaction is willing to pay per unit of gas for the transaction to be executed.
  * `maxPriorityFeePerGas` — the maximum priority fee the sender of the transaction is willing to pay per unit of gas.
  * `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. Used to ensure each transaction is executed only once.
  * `to` — the address of the recipient 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](https://ethereum.org/en/developers/docs/transactions/#types-of-transactions) 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](https://eips.ethereum.org/EIPS/eip-2930#:~:text=The%20accessList%20specifies%20a%20list,of%20accessing%20outside%20the%20list.) the transaction plans to interact with.
  * `v` — the recovery parameter in the [Ethereum Signature Algorithm](https://ethereum.org/en/glossary/#ecdsa) (ECDSA).
  * `r` — the first component of the signature in the [Ethereum Signature Algorithm](https://ethereum.org/en/glossary/#ecdsa) (ECDSA).
  * `s` — the second component of the signature in the [Ethereum Signature Algorithm](https://ethereum.org/en/glossary/#ecdsa) (ECDSA).

## `eth_getTransactionByHash` code examples

<CodeGroup>
  ```javascript web3.js theme={"system"}
  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("0x1920819ae895661e825fc034706ff66a638b3a0f0d2d6e5262781a36de836769")
  ```

  ```javascript ethers.js theme={"system"}
  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("0x1920819ae895661e825fc034706ff66a638b3a0f0d2d6e5262781a36de836769")
  ```

  ```python web3.py theme={"system"}
  from web3 import Web3  
  node_url = "CHAINSTACK_NODE_URL" 

  web3 = Web3(Web3.HTTPProvider(node_url)) 
  print(web3.eth.get_transaction("0x1920819ae895661e825fc034706ff66a638b3a0f0d2d6e5262781a36de836769")) 
  ```
</CodeGroup>

## Use case

One use case for `eth_getTransactionByHash` is to inspect a specific transaction and display information about it, such as the address that was 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.

Here's an example of how you can achieve this in web3.js:

```javascript index.js theme={"system"}
const Web3 = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);

async function getTransaction(transactionHash) {
  // Get the transaction using the provided transaction hash
  const transaction = await web3.eth.getTransaction(transactionHash)

	// Store the desired parameters in constants
  const sender = transaction.from;
  const block = transaction.blockNumber
  const transactionsCount = transaction.nonce

  // Log the transaction information to the console
  console.log(`Transaction ${transactionHash} was sent from address ${sender}`);
  console.log(`It was included in block ${block}`);
  console.log(`The sender has sent ${transactionsCount} transactions so far\n`);
 }
 
 getTransaction("0x1920819ae895661e825fc034706ff66a638b3a0f0d2d6e5262781a36de836769")
```

In this example, the program starts by connecting to a node endpoint. Then, call the `eth_getTransactionByHash` method and pass in the transaction hash as an argument. The method returns a Promise that resolves to a transaction object, which is used to retrieve the sender address, the block number the transaction was included in, and the address nonce.

The last step is to log the information to the console.

<Note>
  Note that the desired parameters are stored in constants, so you can use them for further processing.
</Note>


## OpenAPI

````yaml /openapi/avalanche_node_api/transactions_info/eth_getTransactionByHash.json POST /8763cb5a211e1d4345acd51bde484c00/ext/bc/C/rpc
openapi: 3.0.0
info:
  title: Chainstack Node API
  version: 1.0.0
  description: This is an API for interacting with a Chainstack node.
servers:
  - url: https://nd-418-459-126.p2pify.com
security: []
paths:
  /8763cb5a211e1d4345acd51bde484c00/ext/bc/C/rpc:
    post:
      tags:
        - Transactions info
      summary: eth_getTransactionByHash
      operationId: getTransactionByHash
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                  default: 1
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: eth_getTransactionByHash
                params:
                  type: array
                  items:
                    type: string
                    title: Transaction hash
                  default:
                    - >-
                      0xb6a5420f6b15efe09bec0b1febb3347808eb1576f74b7e012f253257d04b7a70
      responses:
        '200':
          description: The transaction information
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: object

````