Explorer

Get Tokens

Learn how to retrieve supported tokens using the Okto SDK.

The getTokens function fetches the list of supported tokens from the backend.

Example

import { useOkto } from '@okto_web3/react-native-sdk';
import { getTokens } from '@okto_web3/react-native-sdk'; 
 
function TokensList() {
    const oktoClient = useOkto();
 
    async function fetchTokens() {
        try {
            const tokens = await getTokens(oktoClient); 
            console.log('Supported tokens:', tokens);
        } catch (error) {
            console.error('Error fetching tokens:', error);
        }
    }
 
    return (
        <Pressable onPress={fetchTokens}>
            <Text>Fetch Supported Tokens</Text>
        </Pressable>
    );
}

Method Overview

MethodDescription
async getTokensGet list of supported tokens

Get Tokens

async getTokens(oktoClient: OktoClient) retrieves the list of supported tokens.

Parameters

ParameterTypeDescription
oktoClientOktoClientInstance of OktoClient obtained from useOkto hook

Response

Success Response

Field NameTypeDescription
tokensPromise<Token[]>Array of supported tokens

Note

For error handling: