Explorer
Get Portfolio
Learn how to retrieve a user's portfolio using the Okto SDK.
The getPortfolio
function retrieves the user's complete portfolio, including token holdings across all supported chains.
Example
import { useOkto } from '@okto_web3/react-native-sdk';
import { getPortfolio } from '@okto_web3/react-native-sdk';
import { View, Text, Pressable } from 'react-native';
function Portfolio() {
const oktoClient = useOkto();
async function fetchPortfolio() {
try {
const portfolio = await getPortfolio(oktoClient);
console.log('Portfolio data:', portfolio);
} catch (error) {
console.error('Error fetching portfolio:', error);
}
}
return (
<View>
<Pressable onPress={fetchPortfolio}>
<Text>Fetch Portfolio</Text>
</Pressable>
</View>
);
}
Method Overview
Method | Description |
---|---|
async getPortfolio | Get user's portfolio data |
Get Portfolio
async getPortfolio(oktoClient: OktoClient)
retrieves the user's portfolio data including token holdings and their values.
Parameters
Parameter | Type | Description |
---|---|---|
oktoClient | OktoClient | Instance of OktoClient obtained from useOkto hook |
Response
Success Response
Field Name | Type | Description |
---|---|---|
portfolio | Promise<UserPortfolioData> | User's portfolio data |
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