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

# How to Get a Blockchain Transaction by Hash

> Learn how to fetch detailed transaction data using a transaction hash with the Moralis API.

## Introduction

In this tutorial, you'll learn how to retrieve detailed information about any blockchain transaction using its hash. This is essential for building transaction explorers, tracking payments, or verifying on-chain activity in your application. We'll use the following Moralis API endpoint:

* [Get Transaction by Hash](/data-api/evm/blockchain/transaction-by-hash) - Fetch detailed transaction data using a transaction hash

## Prerequisites

* Node.js v18+ installed
* A Moralis API key ([get one free](https://admin.moralis.io))

## Step 1: Set Up Your Project

Create a new directory for your project and initialize it:

```bash theme={null}
mkdir get-transaction && cd get-transaction
npm init -y
```

## Step 2: Create the Script

Create a file called `index.js` and add the following code:

```javascript theme={null}
// index.js
const API_KEY = 'YOUR_API_KEY';
const TX_HASH = '0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060';

async function getTransaction() {
  const response = await fetch(
    `https://deep-index.moralis.io/api/v2.2/transaction/${TX_HASH}?chain=eth`,
    {
      headers: {
        'X-API-Key': API_KEY,
      },
    }
  );

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

getTransaction();
```

Replace `YOUR_API_KEY` with your actual Moralis API key.

## Step 3: Run the Script

Execute the script to fetch the transaction details:

```bash theme={null}
node index.js
```

## Example Response

```json theme={null}
{
  "hash": "0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060",
  "nonce": "0",
  "transaction_index": "0",
  "from_address": "0xa1e4380a3b1f749673e270229993ee55f35663b4",
  "from_address_label": null,
  "to_address": "0x5df9b87991262f6ba471f09758cde1c0fc1de734",
  "to_address_label": null,
  "value": "31337000000000000",
  "gas": "21000",
  "gas_price": "20000000000",
  "input": "0x",
  "receipt_cumulative_gas_used": "21000",
  "receipt_gas_used": "21000",
  "receipt_status": "1",
  "block_timestamp": "2015-08-07T03:30:33.000Z",
  "block_number": "46147",
  "block_hash": "0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd",
  "transaction_fee": "0.00042"
}
```

## Understanding the Response

| Field             | Description                                  |
| ----------------- | -------------------------------------------- |
| `hash`            | The transaction hash                         |
| `from_address`    | The sender's wallet address                  |
| `to_address`      | The recipient's wallet address               |
| `value`           | Amount transferred in wei                    |
| `gas`             | Gas limit set for the transaction            |
| `gas_price`       | Gas price in wei                             |
| `receipt_status`  | Transaction status (1 = success, 0 = failed) |
| `block_timestamp` | When the transaction was mined               |
| `block_number`    | Block number containing this transaction     |
| `transaction_fee` | Total fee paid in native token               |

## Next Steps

* [Get Wallet Transaction History](/get-started/tutorials/data-api/wallets-and-accounts/get-full-wallet-transaction-history-eoa-and-smart-accounts) - Fetch all transactions for a wallet
* [Find Block by Timestamp](/get-started/tutorials/data-api/blocks-and-transactions/find-the-closest-block-by-unix-timestamp) - Find blocks at specific times
