Query Transaction Details by TxHash – Web3 Wallet API Guide

·

Understanding blockchain transaction data is essential for developers, analysts, and crypto enthusiasts alike. Whether you're debugging a failed transfer, verifying asset movements, or building a blockchain explorer interface, being able to retrieve precise on-chain information by transaction hash (TxHash) is a foundational capability.

This guide dives deep into how to use the Wallet-as-a-Service Web3 API to query detailed transaction data using a TxHash. We’ll walk through the endpoint structure, request and response parameters, and explain how transactions—including internal transfers and token movements—are structured in the response.


How to Query Transaction Details by TxHash

The Wallet API allows developers to fetch comprehensive details about any transaction on supported blockchains by providing its unique transaction hash. This includes not only top-level transfers but also internal contract interactions and token movements—all broken down into intuitive sub-transaction types.

Sub-Transaction Type Classification

To enhance clarity and usability, the API categorizes different layers of activity within a single transaction:

This classification helps distinguish between simple wallet-to-wallet sends and complex contract-involved operations.


API Endpoint

Use the following GET request to retrieve transaction details:

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

👉 Get real-time transaction insights with powerful Web3 tools


Request Parameters

To successfully call this endpoint, include the following parameters:

ParameterTypeRequiredDescription
chainIndexStringYesUnique identifier for the blockchain (e.g., "eth-mainnet")
txHashStringYesThe transaction hash (TxHash) to query
iTypeStringNoFilter by sub-transaction type: 0, 1, or 2. If omitted, returns all types.
Note: The iType parameter is particularly useful when you're only interested in token transfers (2) or want to filter out contract-level native coin movements.

Response Parameters

The API returns a richly detailed JSON object with full transaction context. Below is a breakdown of each field returned.

Core Transaction Metadata


Input and Output Details

Each transaction includes arrays that map inputs (fromDetails) and outputs (toDetails) with granular precision.

fromDetails[]

An array listing all input sources:

toDetails[]

An array listing all output destinations:

These fields are especially valuable for reconstructing fund flows and detecting multi-output transactions like token distributions or exchange withdrawals.


Internal Transactions & Token Transfers

Smart contract interactions often trigger internal value transfers or token movements that aren’t visible in the main transaction. The API surfaces these transparently.

internalTransactionDetails[]

Captures native coin movements generated during contract execution:

👉 Unlock advanced on-chain analytics with seamless API access


tokenTransferDetails[]

Reveals all ERC-20/BEP-20/etc. token movements triggered by the transaction:

This section is critical for tracking token swaps, airdrops, staking rewards, and DeFi interactions.


Example Use Cases

1. Verifying User Deposits in a DApp

A decentralized exchange can use this API to monitor incoming deposits by querying user-submitted TxHashes and validating amounts and token contracts.

2. Detecting Failed Transactions

By checking txStatus === '3', applications can alert users of failed transactions and suggest corrective actions like increasing gas fees.

3. Reconciling Accounting Records

Finance teams in crypto-native firms can automate reconciliation by pulling historical transaction data with accurate timestamps and fees.

4. Building Custom Block Explorers

Developers can use this structured data to render user-friendly transaction pages with input/output graphs and token movement timelines.


Frequently Asked Questions (FAQ)

Q: Can I use this API to track transactions on multiple blockchains?
A: Yes. As long as the chain is supported and you provide the correct chainIndex, you can query transactions across various networks including Ethereum, BSC, Polygon, and more.

Q: What happens if I query an invalid or non-existent TxHash?
A: The API will return an error response indicating that the transaction was not found. Always validate TxHash format (typically 66 characters starting with "0x") before making requests.

Q: Is there rate limiting on this endpoint?
A: Yes. To ensure service stability, API calls are subject to rate limits based on your plan. Refer to OKX’s official documentation for exact thresholds.

Q: How soon after broadcast can I query a pending transaction?
A: You can query as soon as the TxHash is available. The API will return status 1 (pending) until it’s confirmed or dropped.

Q: Does this support both EVM and non-EVM chains?
A: The structure applies primarily to EVM-compatible chains. Non-EVM chains may have limited support or require different handling for UTXO-based models.

Q: Can I filter responses to show only token transfers?
A: Yes. Use the optional iType=2 parameter to retrieve only token transfer events within a transaction.


Core Keywords for SEO


👉 Access reliable, high-performance Web3 APIs for real-time blockchain data

With robust support for multi-layered transaction inspection, this API empowers developers to build transparent, secure, and user-friendly blockchain applications. Whether you're analyzing gas efficiency, tracing fund origins, or validating token transfers, querying by TxHash gives you full visibility into on-chain activity.