Explorer
Get Portfolio NFTs
Learn how to retrieve a user's NFT holdings using the Okto SDK.
The getPortfolioNFT
function retrieves all NFTs owned by the user across supported chains.
Example
import { useOkto } from '@okto_web3/react-native-sdk';
import { getPortfolioNFT } from '@okto_web3/react-native-sdk';
import { View, Text, Pressable } from 'react-native';
function NFTPortfolio() {
const oktoClient = useOkto();
async function fetchNFTs() {
try {
const nfts = await getPortfolioNFT(oktoClient);
console.log('NFT holdings:', nfts);
} catch (error) {
console.error('Error fetching NFTs:', error);
}
}
return (
<View>
<Pressable onPress={fetchNFTs}>
<Text>Fetch NFT Holdings</Text>
</Pressable>
</View>
);
}
Note
This function is currently not supported for the following chains:
- Base Sepolia
- HyperEVM
Method Overview
Method | Description |
---|---|
async getPortfolioNFT | Get user's NFT holdings |
Get Portfolio NFT
async getPortfolioNFT(oktoClient: OktoClient)
retrieves the user's NFT portfolio data.
Parameters
Parameter | Type | Description |
---|---|---|
oktoClient | OktoClient | Instance of OktoClient obtained from useOkto hook |
Response
Success Response
Field Name | Type | Description |
---|---|---|
nfts | Promise<NFTData[]> | Array of user's NFT holdings |
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