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

import { useOkto } from '@okto_web3/react-sdk';
import { getNftCollections } from '@okto_web3/react-sdk'; 
 
function NFTCollectionsList() {
    const oktoClient = useOkto();
 
    async function fetchCollections() {
        try {
            const collections = await getNftCollections(oktoClient); 
            console.log('NFT Collections:', collections);
        } catch (error) {
            console.error('Error fetching collections:', error);
        }
    }
 
    return (
        <button onClick={fetchCollections}>
            Fetch NFT Collections
        </button>
    );
}

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

Response

Success Response

Field NameTypeDescription
collectionsPromise<NFTCollection[]>Array of NFT collections

On this page