Query Transaction Details by TxHash – Web3 Wallet API Guide

·

Understanding blockchain transactions at a granular level is essential for developers, auditors, and analysts working in the Web3 ecosystem. One of the most powerful tools available is the ability to query transaction details by TxHash, enabling deep insights into on-chain activities. This guide explores how to use the Wallet API to retrieve comprehensive data about a specific transaction, including asset movements, internal transfers, and token interactions.

Whether you're debugging smart contracts, verifying fund flows, or building analytics dashboards, this API endpoint delivers precise, structured data tailored for integration into decentralized applications (dApps) and financial monitoring systems.

👉 Unlock real-time transaction insights with powerful Web3 tools


Understanding Transaction Structure in Web3

On blockchain networks, especially EVM-compatible chains, a single transaction can trigger multiple sub-transactions. These include:

The Wallet API decomposes each transaction using a standardized format, assigning sub-transaction types based on asset behavior:

This classification enables developers to parse complex transactions accurately—especially useful when analyzing DeFi interactions, cross-contract calls, or multi-step swaps.


API Endpoint: Retrieve Transaction by TxHash

To fetch detailed information about a specific transaction, use the following GET request:

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

This endpoint supports both standalone transactions and those embedded within smart contract executions. It returns structured JSON output containing metadata, fee details, sender/receiver information, and nested events such as internal calls and token movements.

Request Parameters

ParameterTypeRequiredDescription
chainIndexStringYesUnique chain identifier (e.g., eth-mainnet, okc-mainnet)
txHashStringYesThe transaction hash to query
iTypeStringNoFilter by transaction layer: 0 (outer), 1 (inner), 2 (token)
Note: Omitting iType returns all relevant sub-transactions associated with the given TxHash.

Response Parameters Explained

The API returns a rich dataset that captures every aspect of the transaction lifecycle. Below is a breakdown of key fields:

Core Transaction Metadata

Gas and Fee Details

Asset Transfer Information

Input and Output Details

fromDetails[]

Array of input sources:

toDetails[]

Array of output targets:

👉 See how easy it is to analyze blockchain transactions in real time


Nested Transaction Data

For transactions involving smart contracts or multi-step operations, two additional arrays provide deeper visibility:

internalTransactionDetails[]

Captures value transfers initiated within a contract execution:

Useful for tracking MEV bots, flash loans, or recursive calls.

tokenTransferDetails[]

Records all ERC/BEP-style token movements:

This field is crucial for wallet tracking, compliance reporting, and DeFi portfolio monitoring.

Optional Field


Practical Use Cases

1. Wallet Development

Integrate this API to display complete transaction histories with accurate labels for sends, receives, swaps, and contract interactions.

2. Fraud Detection

Analyze failed transactions (txStatus: 3) and high-gas anomalies to flag suspicious behavior.

3. Audit & Compliance

Extract token transfer trails for AML/KYC checks or financial reporting.

4. Smart Contract Debugging

Trace internal calls and balance changes during contract execution.


Frequently Asked Questions (FAQ)

Q: Can I query any blockchain transaction using this API?
A: Yes, as long as the chain is supported by the Wallet API service. Supported chains include Ethereum, OKC, BSC, Polygon, and more—identified via the chainIndex.

Q: What happens if I enter an invalid or non-existent TxHash?
A: The API will return an error response with a descriptive message such as "Transaction not found" or "Invalid txHash format."

Q: How quickly does the API reflect pending transactions?
A: Near real-time. Pending transactions (txStatus: 1) are typically available within seconds of broadcast to the mempool.

Q: Is there rate limiting on this endpoint?
A: Yes. To ensure service stability, usage is subject to fair access policies. Developers should implement caching and efficient polling strategies.

Q: Can I filter results to only show token transfers?
A: Absolutely. Set the optional parameter iType=2 to retrieve only token transfer events within the transaction.

Q: Does this work for failed transactions?
A: Yes. Failed transactions are fully recorded with gas usage and error context, helping developers diagnose issues like out-of-gas or revert conditions.

👉 Start exploring blockchain data with advanced Web3 APIs today


Conclusion

Being able to query transaction details by TxHash is foundational for building transparent, reliable Web3 applications. With granular access to inputs, outputs, internal calls, and token movements, developers gain full visibility into on-chain behavior.

By leveraging the Wallet API's robust structure and consistent response format, you can streamline dApp development, enhance security monitoring, and deliver richer user experiences across wallets, exchanges, and analytics platforms.

Whether you're tracing fund flows or validating smart contract logic, this toolset empowers accurate, scalable blockchain interaction—all through a simple, well-documented interface.

Core keywords: query transaction by txhash, wallet API, Web3 API docs, transaction history, chain info lookup, on-chain data, blockchain transaction details