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 - Fetch detailed transaction data using a transaction hash
Prerequisites
- Node.js v18+ installed
- A Moralis API key (get one free)
Step 1: Set Up Your Project
Create a new directory for your project and initialize it:Step 2: Create the Script
Create a file calledindex.js and add the following code:
YOUR_API_KEY with your actual Moralis API key.
Step 3: Run the Script
Execute the script to fetch the transaction details:Example Response
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 - Fetch all transactions for a wallet
- Find Block by Timestamp - Find blocks at specific times

