Explorer

Get Order History

Learn how to retrieve transaction order history using the Okto SDK.

The getOrderHistory function retrieves the user's transaction order history.

Example

import { useOkto } from '@okto_web3/react-native-sdk';
import { getOrderHistory } from '@okto_web3/react-native-sdk';
import { View, Text, Pressable } from 'react-native'; 
 
function OrderHistory() {
    const oktoClient = useOkto();
 
    async function fetchOrders() {
        try {
            const orders = await getOrderHistory(oktoClient); 
            console.log('Order history:', orders);
        } catch (error) {
            console.error('Error fetching orders:', error);
        }
    }
 
    return (
        <View>
            <Pressable onPress={fetchOrders}>
                <Text>Fetch Order History</Text>
            </Pressable>
        </View>
    );
}

Method Overview

MethodDescription
async getOrderHistoryGet user's order history

Get Order History

async getOrderHistory(oktoClient: OktoClient) retrieves the user's transaction order history.

Parameters

ParameterTypeDescription
oktoClientOktoClientInstance of OktoClient obtained from useOkto hook

Response

Success Response

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

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: