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

# Stellar

> Sign messages and transactions, send XLM and Stellar assets, manage trustlines, and query balances using the Dynamic Flutter SDK.

## Overview

The `StellarModule` provides native Stellar blockchain operations including message signing, transaction envelope signing, XLM and asset transfers, trustlines, balance queries, and network details. Access it via `DynamicSDK.instance.stellar`.

## Prerequisites

* Dynamic SDK initialized (see [Quickstart](/docs/flutter/quickstart))
* User authenticated (see [Authentication](/docs/flutter/authentication))
* Stellar wallet available (see [Wallet Creation](/docs/flutter/wallet-creation))

## Get a Stellar Wallet

If Stellar is enabled in the dashboard, the user gets a Stellar wallet on signup. Find it via `userWallets`:

```dart theme={"system"}
final sdk = DynamicSDK.instance;

final stellarWallet = sdk.wallets.userWallets
    .firstWhereOrNull((wallet) => wallet.chain == 'STELLAR');
```

## Get Balance

Query the XLM balance for a wallet. Returned as a string to preserve precision. Pass `assetCode` and `assetIssuer` to query a non-native asset instead.

```dart theme={"system"}
final balance = await sdk.stellar.getBalance(walletId: wallet.id);
print('Balance: $balance XLM');
```

## Get Network

Query the Stellar network the wallet is connected to:

```dart theme={"system"}
final network = await sdk.stellar.getNetwork(walletId: wallet.id);
print('Network: $network'); // e.g. "PUBLIC"
```

## Sign a Message

Sign a message using the connected Stellar wallet:

```dart theme={"system"}
final signature = await sdk.stellar.signMessage(
  walletId: wallet.id,
  message: 'Hello, Stellar!',
);
print('Signature: $signature');
```

## Sign a Transaction

Sign a base64-encoded transaction envelope XDR. Returns the signed envelope XDR:

```dart theme={"system"}
final signedXdr = await sdk.stellar.signTransaction(
  walletId: wallet.id,
  transactionXdr: envelopeXdr,
);
print('Signed XDR: $signedXdr');
```

## Send a Balance

Send XLM, or a Stellar asset, to a recipient. Returns the transaction hash.

```dart theme={"system"}
final hash = await sdk.stellar.sendBalance(
  walletId: wallet.id,
  toAddress: 'GBUQWP3BOUZX34ULNQG23RQ6F4BV7DVOV4SJQ6FYMJNL3LQO5QFCP5O4',
  amount: '0.01',
);
print('Hash: $hash');
```

| Parameter       | Type      | Description                                               |
| --------------- | --------- | --------------------------------------------------------- |
| `walletId`      | `String`  | The wallet ID to send from                                |
| `toAddress`     | `String`  | Recipient Stellar address (public key)                    |
| `amount`        | `String`  | Amount to send                                            |
| `tokenAddress`  | `String?` | Optional asset in `CODE:ISSUER` form. Omit for native XLM |
| `tokenDecimals` | `int?`    | Optional asset decimals. Stellar uses 7 by default        |

## Add a Trustline

Add a trustline for a non-native asset. An account must hold a trustline for an asset before it can receive it:

```dart theme={"system"}
final hash = await sdk.stellar.addTrustline(
  walletId: wallet.id,
  assetCode: 'USDC',
  assetIssuer: 'GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5',
);
print('Hash: $hash');
```

| Parameter     | Type      | Description                    |
| ------------- | --------- | ------------------------------ |
| `walletId`    | `String`  | The wallet ID                  |
| `assetCode`   | `String`  | The asset code, e.g. `USDC`    |
| `assetIssuer` | `String`  | Public key of the asset issuer |
| `limit`       | `String?` | Optional trustline limit       |

## API Reference

| Method            | Returns          | Description                              |
| ----------------- | ---------------- | ---------------------------------------- |
| `getBalance`      | `Future<String>` | Get wallet balance                       |
| `getNetwork`      | `Future<String>` | Get the connected network, e.g. `PUBLIC` |
| `signMessage`     | `Future<String>` | Sign a message                           |
| `signTransaction` | `Future<String>` | Sign an envelope XDR                     |
| `sendBalance`     | `Future<String>` | Send XLM or an asset, returns tx hash    |
| `addTrustline`    | `Future<String>` | Add an asset trustline, returns tx hash  |

## Next Steps

* [Bitcoin Operations](/docs/flutter/wallets/bitcoin/overview): Bitcoin operations
* [SUI Operations](/docs/flutter/wallets/sui/overview): SUI operations
* [Token Balances](/docs/flutter/wallets/general/token-balances): Multi-chain balance queries
