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

import { useOkto } from '@okto_web3/react-sdk';
import { getPortfolioNFT } from '@okto_web3/react-sdk'; 
 
function NFTPortfolio() {
    const oktoClient = useOkto();
 
    async function fetchNFTPortfolio() {
        try {
            const nftPortfolio = await getPortfolioNFT(oktoClient); 
            console.log('NFT Portfolio:', nftPortfolio);
        } catch (error) {
            console.error('Error fetching NFT portfolio:', error);
        }
    }
 
    return (
        <button onClick={fetchNFTPortfolio}>
            Fetch NFT Portfolio
        </button>
    );
}

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 useOkto hookYes

Response

Success Response

Field NameTypeDescription
nftsPromise<UserNFTBalance[]>Array of user's NFT balances

On this page