Explorer

Get Tokens

Learn how to retrieve token information using the Okto SDK.

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

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

using System;
using System.Threading.Tasks;
using UnityEngine;
 
//This is an independent script which called GetToken() Api
namespace OktoSDK
{
    public class GetToken : MonoBehaviour
    {
        public async Task<object> GetTokens(OktoClient oc)
        {
            if (oc == null)
            {
                ResponsePanel.SetResponse("You are not logged In!");
                return "You are not logged In!";
            }
 
            if (!oc.IsLoggedIn())
            {
                ResponsePanel.SetResponse("You are not logged In!");
                //ResponsePanel.DisplayResponse();
                return "You are not logged In!";
            }
 
            try
            {
                var response = await BffClientRepository.GetBffClientRepository().GetSupportedTokens();
                return response;
            }
            catch (Exception error)
            {
                Debug.LogError($"Error fetching supported tokens: {error}");
                throw new Exception("Failed to fetch supported tokens from the backend.");
            }
        }
    }
}

Note

For error handling:

Method Overview

MethodDescription
async GetTokensGet supported token information

Get Tokens

async GetTokens(oktoClient: OktoClient) retrieves information about all supported tokens.

Parameters

ParameterTypeDescriptionRequired
oktoClientOktoClientInstance of OktoClient obtained from OktoClient.csYes

Response

Success Response

Field NameTypeDescription
tokensTask<List<Token>>Array of supported tokens

On this page