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

# getStellarAssetBalance (Stellar)

> Read a wallet account's balance of a custom Stellar asset.

`getStellarAssetBalance` returns the balance of a custom Stellar asset held by a wallet account on its active network. It returns `"0"` when the account has no trustline for the asset. For the native XLM balance, use [`getNativeBalance`](https://www.dynamic.xyz/docs/javascript/reference/wallets/get-native-balance) instead.

## Usage

```javascript theme={"system"}
import { getStellarAssetBalance, isStellarWalletAccount } from '@dynamic-labs-sdk/stellar';
import { getPrimaryWalletAccount } from '@dynamic-labs-sdk/client';

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isStellarWalletAccount(walletAccount)) {
  const { balance } = await getStellarAssetBalance({
    walletAccount,
    assetCode: 'USDC',
    assetIssuer: 'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
  });

  console.log('USDC balance:', balance);
}
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `assetCode` | `string` | The asset code (e.g. `"USDC"`) |
| `assetIssuer` | `string` | The asset issuer's Stellar account address |
| `walletAccount` | `StellarWalletAccount` | The Stellar wallet account to read the balance of |
| `client` | `DynamicClient` | (optional) The Dynamic client instance. Only required when using multiple Dynamic clients |

## Returns

`Promise<{ balance: string }>` - A promise that resolves to an object containing the balance as a decimal string in the asset's display units.

## Errors

| Error | Description |
| - | - |
| `InvalidParamError` | Thrown if the wallet account is not a Stellar wallet account, or the asset code or issuer is malformed |
| `ValueMustBeDefinedError` | Thrown if the account has no active network data |
| `FetchStellarBalanceError` | Thrown if the balance cannot be retrieved |

## Related functions

* [addTrustline](https://www.dynamic.xyz/docs/javascript/reference/stellar/add-trustline.md) - Add a trustline for a custom asset
* [getNativeBalance](https://www.dynamic.xyz/docs/javascript/reference/wallets/get-native-balance.md) - Read the native XLM balance
* [getTokenBalances](https://www.dynamic.xyz/docs/javascript/reference/wallets/get-token-balances.md) - Read all token balances for a wallet account


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