Explorer

Get NFT Collections

Learn how to retrieve NFT collections using the Okto SDK.

The getNftCollections function retrieves NFT collection details for the authenticated user 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
Polygon Amoy
Polygon Amoy

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

Not available on

Base Sepolia
Base Sepolia
HyperEVM Testnet
HyperEVM Testnet

Example

using System;
using System.Threading.Tasks;
using UnityEngine;
 
//This is an independent script which calls GetNftPotfolio() Api
namespace OktoSDK
{
    public class NFT : MonoBehaviour
    {
 
        public async Task<object> GetNftCollections(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().GetPortfolioNft();
                return response;
            }
            catch (Exception error)
            {
                Debug.LogError($"Error fetching NFT collections: {error}");
                throw new Exception("Failed to fetch NFT collections from the backend.");
            }
        }
    }
 
}

Note

For error handling:

Method Overview

MethodDescription
async GetNftCollectionsGet NFT collections for the user

Get NFT Collections

async GetNftCollections(oktoClient: OktoClient) retrieves the list of NFT collections associated with the user.

Parameters

ParameterTypeDescriptionRequired
oktoClientOktoClientInstance of OktoClient obtained from OktoClient.csYes

Response

Success Response

Field NameTypeDescription
collectionsTask<List<NFTBalance>>List of NFT collections

On this page