Skip to main content
Retrieves a SuiClient instance from a wallet account, allowing you to interact with the Sui blockchain.

Usage

import { getSuiClient, isSuiWalletAccount } from '@dynamic-labs-sdk/sui';
import { getPrimaryWalletAccount } from '@dynamic-labs-sdk/client';

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isSuiWalletAccount(walletAccount)) {
  const suiClient = await getSuiClient({ walletAccount });

  // Use the client to interact with the Sui blockchain
  const balance = await suiClient.getBalance({
    owner: walletAccount.address,
  });

  console.log('Balance:', balance);
}

Parameters

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

Returns

Promise<SuiClient> - A promise that resolves to a SuiClient instance from @mysten/sui.

Errors

ErrorDescription
NotSuiProviderErrorThrown if the wallet account’s provider is not a Sui provider