Skip to main content
Retrieves an Aptos client instance from a wallet account, allowing you to interact with the Aptos blockchain.

Usage

import { getAptosClient, isAptosWalletAccount } from '@dynamic-labs-sdk/aptos';
import { getPrimaryWalletAccount } from '@dynamic-labs-sdk/client';

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isAptosWalletAccount(walletAccount)) {
  const aptosClient = await getAptosClient({ walletAccount });

  // Use the client to interact with the Aptos blockchain
  const balance = await aptosClient.getAccountAPTAmount({
    accountAddress: walletAccount.address,
  });
}

Parameters

ParameterTypeDescription
walletAccountAptosWalletAccountThe wallet account to get the Aptos client for
clientDynamicClient (optional)The Dynamic client instance. Only required when using multiple clients.

Returns

Promise<AptosClient> - A promise that resolves to an Aptos client instance from @aptos-labs/ts-sdk.

Errors

ErrorDescription
NotAptosProviderErrorThrown if the wallet account’s provider is not an Aptos provider