Get Specific Transaction Details Using Wallet API

·

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:

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-txhash

Parameters

ParameterTypeRequiredDescription
chainIndexStringYesUnique identifier for the blockchain (e.g., Ethereum Mainnet, BSC).
txHashStringYesThe transaction hash to query.
iTypeStringNoLayer type for EVM transactions (see Sub-Transaction Types above).

API Response

Key Response Fields

ParameterTypeDescription
chainIndexStringBlockchain identifier.
heightStringBlock height containing the transaction.
txStatusString1: Pending, 2: Success, 3: Failed.
txFeeStringTotal transaction fee paid (in native gas token).
internalTransactionDetailsArrayInternal contract calls (e.g., ETH transfers within a smart contract).
tokenTransferDetailsArrayToken transfers (ERC-20/ERC-721).

Nested Fields


Example Use Case

👉 Learn how to optimize gas fees for Ethereum transactions

Scenario: Tracking a decentralized exchange (DEX) swap:

  1. 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.
  2. The tokenTransferDetails array 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?

👉 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.