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:
- Top-level native coin transfers (e.g., ETH, OKT)
- Internal contract-based value transfers
- Token transfers (ERC-20, BEP-20, etc.)
The Wallet API decomposes each transaction using a standardized format, assigning sub-transaction types based on asset behavior:
0: Outer mainchain coin transfer1: Inner contract-level mainchain coin transfer2: Token transfer (fungible tokens via smart contracts)
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-txhashThis 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
| Parameter | Type | Required | Description |
|---|---|---|---|
chainIndex | String | Yes | Unique chain identifier (e.g., eth-mainnet, okc-mainnet) |
txHash | String | Yes | The transaction hash to query |
iType | String | No | Filter 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
chainIndex: Identifies the blockchain network.height: Block number where the transaction was confirmed.txTime: Timestamp in Unix milliseconds.txhash: Unique transaction identifier.txStatus: Status code:1: Pending2: Success3: Failed
Gas and Fee Details
gasLimit,gasUsed,gasPrice: Critical for performance analysis and cost auditing.txFee: Total fee paid (gasUsed × gasPrice).nonce: Sequence number from sender address.
Asset Transfer Information
amount: Value transferred.symbol: Currency ticker (e.g., ETH, USDT).methodId: Function selector if calling a smart contract.
Input and Output Details
fromDetails[]
Array of input sources:
address: Sender addressvinIndex: Input index in current transactionpreVoutIndex: Output index in previous transactiontxhash: Previous transaction hash (used withpreVoutIndex)isContract: Boolean indicating if sender is a contractamount: Input value
toDetails[]
Array of output targets:
address: Receiver addressvoutIndex: Output positionisContract: Whether receiver is a contractamount: Sent amount
👉 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:
from,to: Addresses involvedisFromContract,isToContract: Contract flagsamount,txStatus: Transfer value and status
Useful for tracking MEV bots, flash loans, or recursive calls.
tokenTransferDetails[]
Records all ERC/BEP-style token movements:
from,to: Sender and recipienttokenContractAddress: Address of the token contractsymbol: Token symbol (e.g., DAI, UNI)amount: Quantity transferred (in base units)
This field is crucial for wallet tracking, compliance reporting, and DeFi portfolio monitoring.
Optional Field
l1OriginHash: For Layer 2 chains, this references the original L1 transaction hash—key for cross-layer reconciliation.
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