Explorer

Get Portfolio

Learn how to retrieve portfolio information using the Okto SDK.

The getPortfolio function retrieves the user's portfolio information, including token balances and total portfolio value across all supported chains.

Available on

Ethereum
Ethereum
Polygon
Polygon
Avalanche
Avalanche
Arbitrum
Arbitrum
BSC
BSC
Fantom
Fantom
Linea
Linea
Metis
Metis
Optimism
Optimism
Base
Base
Base Sepolia
Base Sepolia
HyperEVM Testnet
HyperEVM Testnet
Polygon Amoy
Polygon Amoy

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 { getPortfolio } from '@okto_web3/react-sdk'; 
 
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 (
        <button onClick={fetchPortfolio}>
            Fetch Portfolio
        </button>
    );
}

Note

For error handling:

Method Overview

MethodDescription
async getPortfolioGet portfolio information for the user

Get Portfolio

async getPortfolio(oktoClient: OktoClient) retrieves the user's aggregated portfolio data.

Parameters

ParameterTypeDescriptionRequired
oktoClientOktoClientInstance of OktoClient obtained from useOkto hookYes

Response

Success Response

Field NameTypeDescription
portfolioPromise<UserPortfolioData>User's portfolio information

On this page