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
Method | Description |
---|---|
async getOrderHistory | Get user's order history |
Get Order History
async getOrderHistory(oktoClient: OktoClient)
retrieves the user's transaction order history.
Parameters
Parameter | Type | Description |
---|---|---|
oktoClient | OktoClient | Instance of OktoClient obtained from useOkto hook |
Response
Success Response
Field Name | Type | Description |
---|---|---|
orders | Promise<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:
- Use the error code to debug issues. Check out the SDK errors and warnings documentation
- For help, navigate to the troubleshooting guide to contact support