> ## 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.

# addTrustline (Stellar)

> Add a trustline for a custom Stellar asset to a wallet account.

`addTrustline` adds a trustline for a custom Stellar asset to a wallet account, allowing the account to hold and receive that asset. Each trustline reserves a small amount of XLM as base reserve. The wallet provider prompts the user to sign the trustline transaction.

## Usage

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

const walletAccount = getPrimaryWalletAccount();

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

  console.log('Trustline transaction:', transactionHash);
}
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `assetCode` | `string` | The asset code (e.g. `"USDC"`) |
| `assetIssuer` | `string` | The asset issuer's Stellar account address |
| `limit` | `string` | (optional) Maximum balance the account can hold, as a decimal string. Defaults to the network maximum, which replaces any lower limit on an existing trustline |
| `walletAccount` | `StellarWalletAccount` | The Stellar wallet account to add the trustline to |
| `client` | `DynamicClient` | (optional) The Dynamic client instance. Only required when using multiple Dynamic clients |

`limit` must be greater than zero and at most `922337203685.4775807`, with up to 7 decimals. A zero limit would remove the trustline, so it is rejected.

## Returns

`Promise<{ transactionHash: string }>` - A promise that resolves to an object containing the submitted transaction hash. Wait for inclusion with [`confirmTransaction`](https://www.dynamic.xyz/docs/javascript/building-ui/transaction-confirmation#sending-and-confirming).

## Errors

| Error | Description |
| - | - |
| `InvalidParamError` | Thrown if the wallet account is not a Stellar wallet account, or `limit` is not a valid trustline limit |

## Related functions

* [signTransaction](https://www.dynamic.xyz/docs/javascript/reference/stellar/sign-transaction.md) - Sign a Stellar transaction
* [getStellarAssetBalance](https://www.dynamic.xyz/docs/javascript/reference/stellar/get-stellar-asset-balance.md) - Read a custom asset balance
* [isStellarWalletAccount](https://www.dynamic.xyz/docs/javascript/reference/stellar/checking-stellar-wallet-account-type.md) - Check if a wallet account is a Stellar account


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