Explorer

Get Account

Learn how to get the account of a user using the Okto SDK.

Okto SDK provides the getAccount() method to retrieve details of wallets connected to the current user's Okto account. This includes both embedded wallets created via Okto and external wallets connected by the user (e.g., MetaMask, Phantom).

Example

import { useOkto } from '@okto_web3/react-native-sdk';
import { getAccount } from '@okto_web3/react-native-sdk'; 
import { View, Text, Pressable } from 'react-native';
 
function Account() {
    const oktoClient = useOkto();
 
    async function fetchAccount() {
        try {
            const account = await getAccount(oktoClient); 
            console.log('Account data:', account);
        } catch (error) {
            console.error('Error fetching user account:', error);
        }
    }
 
    return (
        <View>
            <Pressable onPress={fetchAccount}>
                <Text>Fetch User Account</Text>
            </Pressable>
        </View>
    );
}

Method Overview

MethodsDescription
async getAccountGet the account of a user

Get Account

async getAccount() retrieves the list of all wallets associated with the currently authenticated user.

In Okto, an account represents the user's identity in the Okto ecosystem, encompassing both embedded wallets seamlessly created by Okto and external wallets users choose to connect.

Parameters

ParameterTypeDescription
oktoClientOktoClientOkto client

Response

Success Response

Field NameTypeDescription
resultPromise<Wallet[]>Returns the list of wallet of the user

Note

For error handling: