Get Specific Transaction Details Using Wallet API

·

Understanding blockchain transaction data is essential for developers, analysts, and crypto enthusiasts. Whether you're tracking fund flows, verifying smart contract interactions, or auditing wallet activity, accessing precise on-chain information is crucial. The Wallet API enables seamless retrieval of detailed transaction data using a transaction hash (txHash). This powerful tool breaks down complex transactions into clear, asset-based sub-transactions, making it easier to interpret multi-layered blockchain operations.

This guide explores how to use the Get Transaction by Hash endpoint to retrieve comprehensive on-chain details, decode transaction components, and analyze various transfer types across EVM-compatible networks.


How the Wallet API Processes Transactions

The Wallet API enhances transparency by decomposing a single transaction into logical sub-transactions based on the type of asset transferred. This breakdown is especially useful for EVM chains where a single transaction may involve native coin transfers, internal contract calls, and token movements.

Each transaction is categorized into one of three sub-transaction types:

By segmenting transactions this way, developers gain granular visibility into every financial action triggered by a single txHash.

👉 Discover how easy it is to retrieve real-time on-chain transaction data with powerful API tools.


API Endpoint: Retrieve Transaction by Hash

Use the following endpoint to fetch full transaction details:

GET https://web3.okx.com/api/v5/wallet/post-transaction/transaction-detail-by-txhash

This request returns structured data including block metadata, fee details, sender/receiver information, internal transactions, and token transfers — all tied to a specific txHash.

Required Request Parameters

To successfully query the API, include these parameters:

ParameterTypeRequiredDescription
chainIndexStringYesUnique identifier for the blockchain (e.g., eth, bsc)
txHashStringYesThe transaction hash to look up
iTypeStringNoFilter by sub-transaction type: 0, 1, or 2

Specifying the iType allows targeted analysis — for example, isolating only token transfers (iType=2) when monitoring ERC-20 activity.


Understanding the Response Structure

The API response delivers a rich dataset that captures every aspect of the transaction. Below is an overview of key fields and their significance.

Core Transaction Metadata

Input and Output Details

The fromDetails and toDetails arrays provide UTXO-style insights into inputs and outputs:

This level of detail supports forensic analysis and helps trace fund origins and destinations.

Internal Transaction Details

Smart contract interactions often trigger internal value transfers not visible at the top level. The internalTransactionDetails array reveals:

These entries are vital for debugging failed contract executions or identifying hidden fund movements.

Token Transfer Insights

For token-based activity, the tokenTransferDetails array includes:

This data powers dApp analytics, portfolio tracking, and compliance reporting.

Additionally, l1OriginHash is included for Layer 2 transactions, linking them back to their original L1 execution — essential for cross-layer auditing.


Practical Use Cases

1. Wallet Activity Monitoring

Developers building non-custodial wallets can use this API to display accurate transaction histories, including token movements and internal calls, ensuring users see a complete picture of their activity.

2. Fraud Detection & Forensics

Security teams can analyze suspicious transactions by inspecting internal transfers and contract interactions. A seemingly small external transfer might conceal large internal value shifts — a red flag for exploits or scams.

3. Gas Optimization Analysis

By reviewing gasUsed, gasPrice, and txFee, developers can benchmark contract efficiency and optimize future deployments.

👉 See how professional-grade Web3 APIs simplify blockchain data access for developers and businesses.


Frequently Asked Questions (FAQ)

What is a sub-transaction in the context of this API?

A sub-transaction refers to a segmented part of a blockchain transaction broken down by asset type. For example, a single Ethereum transaction might include both ETH transfer (type 0) and USDT transfer (type 2). The API separates these for clearer analysis.

Can I filter results to show only token transfers?

Yes. Use the optional parameter iType=2 in your request to retrieve only token transfer records. This is ideal when tracking ERC-20 or BEP-20 movements without noise from native coin transfers.

Why are some addresses marked as contracts?

The isContract field indicates whether an address contains executable code. If true, the address is a smart contract rather than a user-controlled wallet. This distinction helps identify automated behavior or protocol interactions.

How accurate is the transaction status?

The txStatus field reflects finality: pending, success, or fail. Failed transactions typically result from out-of-gas errors or reverted logic in smart contracts. Real-time status updates make this endpoint reliable for monitoring.

Is this API compatible with all EVM chains?

Yes. As long as the chain is supported via its chainIndex, the API works across EVM-compatible networks like Ethereum, Binance Smart Chain, Polygon, Arbitrum, and Optimism.

What does l1OriginHash mean?

It refers to the Layer 1 transaction hash that initiated a Layer 2 operation. For rollups like Arbitrum or Optimism, this field enables tracing transactions back to their root origin on Ethereum, supporting cross-layer reconciliation.


Conclusion

Accessing precise on-chain data has never been more straightforward. With the Wallet API’s transaction detail endpoint, developers can extract comprehensive insights from any transaction using just its hash. From tracking native coin flows to dissecting complex token transfers and internal contract calls, this tool empowers deeper understanding of blockchain behavior.

Whether you're building analytics dashboards, securing protocols, or enhancing wallet functionality, integrating this API streamlines development and improves accuracy.

👉 Start exploring blockchain transactions today with fast, reliable API access.