> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# getSuiClient

# getSuiClient

Retrieves a Sui gRPC client (`SuiGrpcClient` from `@mysten/sui/grpc`) from a wallet account, allowing you to interact with the Sui blockchain.

> [!NOTE]
>
> The Sui RPC URL configured for the wallet's network must serve the Sui gRPC
> API. JSON-RPC endpoints are not supported.

## Usage

```javascript theme={"system"}
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

| Parameter | Type | Description |
| - | - | - |
| `walletAccount` | `SuiWalletAccount` | The wallet account to get the Sui client for |
| `client` | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple clients. |

## Returns

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

## Errors

| Error | Description |
| - | - |
| `NotSuiProviderError` | Thrown if the wallet account's provider is not a Sui provider |

## React

```tsx theme={"system"}
import { getSuiClient, isSuiWalletAccount } from '@dynamic-labs-sdk/sui';
import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
import { useEffect, useState } from 'react';

function SuiBalance() {
  const { data: walletAccounts = [] } = useGetWalletAccounts();
  const walletAccount = walletAccounts.find(isSuiWalletAccount);
  const [balance, setBalance] = useState(null);

  useEffect(() => {
    if (!walletAccount) return;
    getSuiClient({ walletAccount }).then(async (client) => {
      const bal = await client.getBalance({ owner: walletAccount.address });
      setBalance(bal.balance.coinBalance);
    });
  }, [walletAccount]);

  return <p>SUI balance: {balance ?? '...'}</p>;
}
```

## Related functions

* [isSuiWalletAccount](https://docs.dynamic.xyz/docs/javascript/reference/sui/checking-sui-wallet-account-type.md) - Check if a wallet account is a Sui account
* [signAndExecuteTransaction](https://docs.dynamic.xyz/docs/javascript/reference/sui/sign-and-execute-transaction.md) - Sign and execute a transaction


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.