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

# Stellar

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

## Overview

`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.getInstance().stellar`.

## Prerequisites

* Dynamic SDK initialized (see [Quickstart](/docs/kotlin/quickstart))
* User authenticated (see [Authentication](/docs/kotlin/authentication))
* Stellar enabled in the [Dynamic dashboard](https://app.dynamic.xyz/dashboard/chains-and-networks)

## Get a Stellar Wallet

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

```kotlin theme={"system"}
val sdk = DynamicSDK.getInstance()

val stellarWallet = sdk.wallets.userWallets.firstOrNull { it.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.

```kotlin theme={"system"}
val balance = sdk.stellar.getBalance(walletId = wallet.id)
println("Balance: $balance XLM")
```

## Get Network

Query the Stellar network the wallet is connected to:

```kotlin theme={"system"}
val network = sdk.stellar.getNetwork(walletId = wallet.id)
println("Network: $network") // e.g. "PUBLIC"
```

## Sign a Message

Sign a message using the connected Stellar wallet:

```kotlin theme={"system"}
val signature = sdk.stellar.signMessage(
    walletId = wallet.id,
    message = "Hello, Stellar!"
)
println("Signature: $signature")
```

## Sign a Transaction

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

```kotlin theme={"system"}
val signedXdr = sdk.stellar.signTransaction(
    walletId = wallet.id,
    transactionXdr = envelopeXdr
)
println("Signed XDR: $signedXdr")
```

## Send a Balance

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

```kotlin theme={"system"}
val hash = sdk.stellar.sendBalance(
    walletId = wallet.id,
    toAddress = "GBUQWP3BOUZX34ULNQG23RQ6F4BV7DVOV4SJQ6FYMJNL3LQO5QFCP5O4",
    amount = "0.01"
)
println("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:

```kotlin theme={"system"}
val hash = sdk.stellar.addTrustline(
    walletId = wallet.id,
    assetCode = "USDC",
    assetIssuer = "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5",
    limit = null // optional
)
println("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` | `String` | Get wallet balance |
| `getNetwork` | `String` | Get the connected network, e.g. `PUBLIC` |
| `signMessage` | `String` | Sign a message |
| `signTransaction` | `String` | Sign an envelope XDR |
| `sendBalance` | `String` | Send XLM or an asset, returns tx hash |
| `addTrustline` | `String` | Add an asset trustline, returns tx hash |

## Next Steps

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


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