Explorer

Get Portfolio NFTs

Learn how to retrieve NFT portfolio information using the Okto SDK.

The getPortfolioNFT function retrieves the list of NFTs in the authenticated user's portfolio.

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 getPortfolioNFTGet NFT portfolio information

Get Portfolio NFT

async getPortfolioNFT(oktoClient: OktoClient) retrieves the user's NFT portfolio information.

Parameters

ParameterTypeDescriptionRequired
oktoClientOktoClientInstance of OktoClient obtained from OktoClient.csYes

Response

Success Response

Field NameTypeDescription
nftsTask<List<UserNFTBalance>>Array of user's NFT balances

On this page