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

MethodDescription
async getPortfolioGet user's portfolio data

Get Portfolio

async getPortfolio(oktoClient: OktoClient) retrieves the user's portfolio data including token holdings and their values.

Parameters

ParameterTypeDescription
oktoClientOktoClientInstance of OktoClient obtained from useOkto hook

Response

Success Response

Field NameTypeDescription
portfolioPromise<UserPortfolioData>User's portfolio data

Note

For error handling: