Explorer

Get Orders History

Learn how to retrieve order history using the Okto SDK.

The getOrdersHistory function retrieves the transaction history of orders placed by the authenticated user.

Available on

Ethereum
Ethereum
Polygon
Polygon
Avalanche
Avalanche
Arbitrum
Arbitrum
BSC
BSC
Fantom
Fantom
Linea
Linea
Metis
Metis
Optimism
Optimism
Base
Base
Base Sepolia
Base Sepolia
HyperEVM Testnet
HyperEVM Testnet
Polygon Amoy
Polygon Amoy

To enable these chains for your application, please configure them in the Okto Dashboard.

Not available on

Example

import { useOkto } from '@okto_web3/react-sdk';
import { getOrdersHistory } from '@okto_web3/react-sdk'; 
 
function OrderHistory() {
    const oktoClient = useOkto();
 
    async function fetchOrderHistory() {
        try {
            const history = await getOrdersHistory(oktoClient); 
            console.log('Order history:', history);
        } catch (error) {
            console.error('Error fetching order history:', error);
        }
    }
 
    return (
        <button onClick={fetchOrderHistory}>
            Fetch Order History
        </button>
    );
}

Important: Transaction Lifecycle

The getOrderHistory function fetches the current status of a transaction on the Okto chain. However, the transaction status will continue to update on the Okto chain as it progresses through various stages in the Distributed Transaction Network (DTN).

To track a transaction to completion:

  • Keep fetching the order history for your specific jobId until the status shows "SUCCESSFUL"
  • Once successful, the transaction hash will be available in the response
  • Use this transaction hash to verify the transaction on the destination chain's explorer

Note

For error handling:

Method Overview

MethodDescription
async getOrdersHistoryGet order history for the user

Get Orders History

async getOrdersHistory(oktoClient: OktoClient, filters?: OrderFilterRequest) retrieves the transaction history of orders placed by the user.

Parameters

ParameterTypeDescriptionRequired
oktoClientOktoClientInstance of OktoClient obtained from useOkto hookYes
filtersOrderFilterRequestOptional filters for the orders queryNo

Where OrderFilterRequest contains:

FieldTypeDescription
intentIdstringOptional ID to filter specific order/transaction
statusSTATUS_TYPEOptional status to filter orders by (e.g., "SUCCESSFUL", "FAILED", "PENDING", "REJECTED")
intentTypeINTENT_TYPEOptional type to filter orders by (e.g., "TOKEN_TRANSFER", "NFT_TRANSFER", "RAW_TRANSACTION")

Response

Success Response

Field NameTypeDescription
ordersPromise<Order[]>Array of order history items

On this page