The Wallet API allows you to retrieve detailed information about a blockchain transaction using its txHash. It intelligently decomposes transactions (including internal transactions) into sub-transactions based on asset type for clearer analysis.
Sub-Transaction Types
The API categorizes transactions as follows:
0: Outer layer mainnet coin transfer1: Inner layer mainnet coin transfer within a contract2: Token transfer
For EVM-compatible chains, this classification helps users track fund flows across different layers.
API Request
Request Path
GET https://web3.okx.com/api/v5/wallet/post-transaction/transaction-detail-by-txhashParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
chainIndex | String | Yes | Unique identifier for the blockchain (e.g., Ethereum Mainnet, BSC). |
txHash | String | Yes | The transaction hash to query. |
iType | String | No | Layer type for EVM transactions (see Sub-Transaction Types above). |
API Response
Key Response Fields
| Parameter | Type | Description |
|---|---|---|
chainIndex | String | Blockchain identifier. |
height | String | Block height containing the transaction. |
txStatus | String | 1: Pending, 2: Success, 3: Failed. |
txFee | String | Total transaction fee paid (in native gas token). |
internalTransactionDetails | Array | Internal contract calls (e.g., ETH transfers within a smart contract). |
tokenTransferDetails | Array | Token transfers (ERC-20/ERC-721). |
Nested Fields
fromDetails/toDetails:address: Sender/receiver address.isContract: Whether the address is a smart contract.amount: Transferred value.
tokenTransferDetails:tokenContractAddress: Contract address of the token.symbol: Token symbol (e.g., USDT).
Example Use Case
👉 Learn how to optimize gas fees for Ethereum transactions
Scenario: Tracking a decentralized exchange (DEX) swap:
The API breaks down the transaction into:
- A
2-type sub-transaction for the token swap. - A
0-type sub-transaction for the gas fee payment.
- A
- The
tokenTransferDetailsarray reveals the exact tokens swapped and their amounts.
FAQs
1. How does the API handle failed transactions?
Failed transactions (txStatus = 3) include revert reasons in the methodId field, helping debug smart contract interactions.
2. Can I query cross-chain transactions?
No—this API retrieves details only for transactions on a single specified chain (chainIndex).
3. What’s the difference between gasUsed and gasLimit?
gasLimit: Maximum gas the sender is willing to spend.gasUsed: Actual gas consumed by the transaction.
👉 Explore advanced Wallet API features
Pro Tip: Use the l1OriginHash field for Layer 2 transactions (e.g., Optimism, Arbitrum) to trace back to the originating Layer 1 transaction.