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
To enable these chains for your application, please configure them in the Okto Dashboard.
Not available on
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:
- Use the error code to debug issues. Check out the SDK errors and warnings documentation
- For help, navigate to the troubleshooting guide to contact support
Method Overview
| Method | Description |
|---|---|
async getPortfolioNFT | Get NFT portfolio information |
Get Portfolio NFT
async getPortfolioNFT(oktoClient: OktoClient) retrieves the user's NFT portfolio information.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
oktoClient | OktoClient | Instance of OktoClient obtained from useOkto hook | Yes |
Response
Success Response
| Field Name | Type | Description |
|---|---|---|
nfts | Promise<UserNFTBalance[]> | Array of user's NFT balances |