Embedded wallets

Learn how to create embedded wallets for users within your application using the Okto SDK.

Creating Embedded Wallets

Okto's embedded wallets provide a seamless way to integrate wallet functionality into your application. This guide explains how to create and manage embedded wallets for your users.

Automatic Wallet Creation

Okto automatically handles wallet creation for your users. When a user authenticates with your application, Okto creates their embedded wallet addresses across supported chains. This means:

  1. No manual wallet creation is required
  2. Wallets are instantly available after authentication
  3. Users can immediately start interacting with supported chains

Accessing User Wallets

To retrieve a user's wallets across different chains, use the getAccount function:

import { useOkto, getAccount } from '@okto_web3/react-sdk';
 
function WalletExample() {
    const oktoClient = useOkto();
    
    async function fetchUserWallets() {
        try {
            const wallets = await getAccount(oktoClient);
            console.log('User wallets:', wallets);
            // Example response:
            // {
            //     "status": "success",
            //     "data": [
            //         {
            //             "caip_id": "eip155:1",
            //             "network_name": "ETHEREUM",
            //             "address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
            //             "network_id": "1",
            //             "network_symbol": "ETH"
            //         },
            //         // ... other chain wallets
            //     ]
            // }
        } catch (error) {
            console.error('Error fetching wallets:', error);
        }
    }
    
    return (
        <button onClick={fetchUserWallets}>
            View My Wallets
        </button>
    );
}

Note

Ensure that the user is authenticated before calling getAccount(). You should prompt users to log in if they are not already authenticated.

On this page