Understanding blockchain transaction data is essential for developers, analysts, and Web3 applications requiring real-time, accurate on-chain insights. The Wallet API enables precise retrieval of transaction details using a txHash, breaking down complex transactions into structured sub-transactions by asset type. This guide walks you through how to query a specific transaction, interpret its components, and leverage the response for deeper blockchain analysis.
Whether you're verifying payments, auditing smart contracts, or building wallet infrastructure, mastering transaction detail extraction is foundational to Web3 development.
How to Retrieve a Transaction by Hash
To get comprehensive information about a specific blockchain transaction, use the following endpoint:
GET https://web3.okx.com/api/v5/wallet/post-transaction/transaction-detail-by-txhashThis API call returns full on-chain data associated with the provided transaction hash (txHash), including metadata, input/output details, gas usage, and nested operations like internal transfers and token movements.
Required Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
chainIndex | String | Yes | Unique identifier for the blockchain (e.g., eth-mainnet, polygon-mainnet) |
txHash | String | Yes | The transaction hash (66-character hex string starting with 0x) |
iType | String | No | Filter by sub-transaction layer: 0 = outer mainnet coin transfer, 1 = inner contract transfer, 2 = token transfer |
🔍 Tip: While iType is optional, specifying it helps filter results when analyzing multi-layered EVM transactions involving native coins and tokens.Understanding the Response Structure
The Wallet API decomposes each transaction into logical sub-transactions based on asset behavior—especially useful for EVM-compatible chains where one transaction can trigger multiple value transfers.
Core Transaction Metadata
chainIndex: Identifies the network (e.g., Ethereum Mainnet).height: Block number in which the transaction was confirmed.txTime: Timestamp in Unix milliseconds—ideal for chronological sorting.txhash: Unique identifier of the transaction.txStatus: Current state:1: Pending2: Success3: Failed
gasLimit,gasUsed,gasPrice: Key metrics for cost calculation and performance analysis.txFee: Total fee paid (in native currency).nonce: Sequence number from sender’s address.amount,symbol: Value and currency symbol (e.g., ETH, MATIC) transferred at the top level.
👉 Access real-time transaction data with powerful Web3 tools
Analyzing Input and Output Details
Each transaction consists of inputs (fromDetails) and outputs (toDetails), mirroring UTXO-style accounting even on account-based EVM chains.
From Details (Inputs)
An array listing all funding sources:
address: Sender addressvinIndex: Input index within this transactionpreVoutIndex: Output index in the prior transaction (used to trace UTXOs)txhash: Reference to the source transactionisContract: Indicates if sender is a smart contractamount: Sent value
To Details (Outputs)
Receivers of funds in this transaction:
address: Recipient addressvoutIndex: Position of output in this transactionisContract: Whether recipient is a contractamount: Received amount
These fields are critical for balance tracking, forensics, and identifying interaction patterns between wallets and protocols.
Internal Transactions & Token Transfers
Complex transactions—especially those interacting with DeFi protocols or NFT marketplaces—often involve internal operations not visible in the primary transfer.
Internal Transaction Details
Captures value movements initiated within a smart contract execution:
from,to: Addresses involved in internal transferisFromContract,isToContract: Flags indicating contract involvementamount,txStatus: Value moved and outcome
Useful for detecting hidden withdrawals or contract logic exploits.
Token Transfer Details
Lists all ERC-20, ERC-721, or ERC-1155 token movements triggered by the transaction:
from,to: Token sender and receivertokenContractAddress: Address of the token contractsymbol: Token ticker (e.g., USDT, WETH)amount: Quantity transferred (formatted based on token decimals)
This section is indispensable for dApp developers tracking user deposits, swaps, or NFT mints.
Real-World Use Cases
1. Payment Verification
E-commerce platforms or SaaS services accepting crypto can validate incoming payments by checking txStatus, amount, and recipient address against their records.
2. Smart Contract Auditing
Security researchers analyze internal transactions and token flows to detect reentrancy risks or unexpected fund routing.
3. On-Chain Analytics Dashboards
Aggregating data from multiple transactions allows creation of portfolio trackers, gas optimization tools, or wallet activity timelines.
👉 Explore advanced blockchain querying capabilities today
Frequently Asked Questions (FAQ)
Q: What does "sub-transaction decomposition" mean?
A: It means breaking down a single blockchain transaction into its component actions—like native coin transfers, internal calls, and token movements—for granular analysis.
Q: Can I use this API to track failed transactions?
A: Yes. Check the txStatus field: a value of 3 indicates failure. You can also review gasUsed—if close to gasLimit, it may have run out of gas.
Q: How do I identify ERC-20 transfers in the response?
A: Look under tokenTransferDetails. Each entry includes a tokenContractAddress and symbol, helping distinguish between different tokens sent in one transaction.
Q: Is there rate limiting on this API endpoint?
A: While specific limits aren’t listed here, best practice is to cache responses and avoid excessive polling. For high-frequency needs, consider WebSocket alternatives or batch queries.
Q: Does this support non-EVM blockchains?
A: The core structure applies broadly, but decomposition logic (especially internal transactions) is most relevant for EVM chains like Ethereum, BSC, or Arbitrum.
Q: What is l1OriginHash used for?
A: On Layer 2 networks (e.g., Optimism, Arbitrum), this field links an L2 transaction back to its originating L1 transaction hash for cross-layer traceability.
Best Practices for Integration
- Always validate the
txStatusbefore acting on transaction data. - Cross-check
amountandsymbolwith your expected values to prevent spoofing. - Use
txTimeto maintain chronological order in user activity logs. - Monitor
gasUsed / gasLimitratio to detect inefficient executions. - Store
noncefor detecting replay attacks or out-of-order submissions.
For developers building custodial solutions or multi-signature wallets, combining this data with address labeling and risk scoring enhances security and usability.
👉 Unlock seamless on-chain data access with trusted Web3 infrastructure
Final Thoughts
The ability to extract and interpret detailed transaction information lies at the heart of modern blockchain development. With the Wallet API’s structured breakdown of transactions by asset type—native transfers, internal calls, and token movements—you gain unparalleled visibility into on-chain behavior.
Whether you're debugging a failed swap, verifying a payment, or building an analytics engine, leveraging this API ensures accuracy, efficiency, and scalability across your Web3 projects.
By integrating these insights responsibly and securely, you empower both your application and your users with transparent, real-time blockchain intelligence.