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:
0: Outer-layer native coin transfer (e.g., ETH, BTC)1: Inner-layer native coin transfer within a smart contract call2: Token transfer (ERC-20, BEP-20, etc.)
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:
| Parameter | Type | Required | Description |
|---|---|---|---|
chainIndex | String | Yes | Unique identifier for the blockchain (e.g., "eth-mainnet") |
txHash | String | Yes | The transaction hash (TxHash) to query |
iType | String | No | Filter by sub-transaction type: 0, 1, or 2. If omitted, returns all types. |
Note: TheiTypeparameter 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
chainIndex: Identifier of the blockchain network.height: Block number where the transaction was confirmed.txTime: Timestamp in Unix milliseconds format.txhash: The queried transaction hash.txStatus: Current status:1: Pending2: Success3: Failed
gasLimit,gasUsed,gasPrice: Gas metrics for EVM chains.txFee: Total transaction fee calculated asgasUsed × gasPrice.nonce: Sender’s transaction count at time of submission.amount,symbol: Value and ticker of transferred native asset.methodId: First 4 bytes of the function selector called in a smart contract (if applicable).l1OriginHash: On L2 networks, this shows the corresponding L1 transaction hash.
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:
address: Source wallet or contract address.vinIndex: Index of this input within the current transaction.preVoutIndex: Index of the output in the previous transaction (UTXO model reference).txhash: Previous transaction hash that created this UTXO.isContract: Boolean indicating if the sender is a smart contract.amount: Amount deducted from this input.
toDetails[]
An array listing all output destinations:
address: Recipient wallet or contract address.voutIndex: Output index in this transaction.isContract: Indicates whether the receiver is a contract.amount: Amount sent to this output.
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:
from,to: Addresses involved in internal transfer.isFromContract,isToContract: Flags for contract involvement.amount: Value transferred internally.txStatus: Status of the internal operation.
👉 Unlock advanced on-chain analytics with seamless API access
tokenTransferDetails[]
Reveals all ERC-20/BEP-20/etc. token movements triggered by the transaction:
from,to: Sender and recipient addresses.isFromContract,isToContract: Whether either party is a contract.tokenContractAddress: Address of the token’s smart contract.symbol: Token ticker (e.g., USDT, UNI).amount: Quantity transferred (in human-readable units, considering decimals).
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
- Transaction details by TxHash
- Blockchain transaction lookup
- Web3 wallet API
- On-chain data query
- Token transfer tracking
- Smart contract interaction analysis
- Wallet-as-a-Service API
- Internal transaction details
👉 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.