Skip to main content
Use WalletType.stellar to create or load a Stellar wallet, then pass a StellarTransaction value to signTransaction.

Quick start

StellarSigning.swift
import ParaSwift

let paraManager = ParaManager(apiKey: "your-api-key")

enum StellarWalletError: Error {
    case notFound
}

func getOrCreateStellarWallet(_ paraManager: ParaManager) async throws -> Wallet {
    var wallets = try await paraManager.fetchWallets()
    if let wallet = wallets.first(where: { $0.type == .stellar }) {
        return wallet
    }

    try await paraManager.createWallet(type: .stellar, skipDistributable: false)
    wallets = try await paraManager.fetchWallets()

    guard let wallet = wallets.first(where: { $0.type == .stellar }) else {
        throw StellarWalletError.notFound
    }
    return wallet
}

let wallet = try await getOrCreateStellarWallet(paraManager)

let transaction = StellarTransaction(
    to: "GRECIPIENT_STELLAR_ADDRESS",
    amount: "10",
    memo: .text("hello"),
    networkPassphrase: StellarNetwork.testnetPassphrase
)

let result = try await paraManager.signTransaction(
    walletId: wallet.id,
    transaction: transaction
)

print("Signed transaction: \(result.signedTransaction)")

Display the address

A Stellar wallet uses the same Wallet model as the other wallet types. Use wallet.stellarAddress to derive the Stellar G-address from the wallet public key when needed.
StellarAddress.swift
let address = wallet.stellarAddress ?? wallet.address
print("Stellar address: \(address ?? "No address")")
You can also call the address helpers directly:
StellarAddressHelpers.swift
let address = try StellarAddress.fromPublicKey(publicKeyHex)
let addressFromSolana = try StellarAddress.fromSolanaAddress(solanaAddress)

Sign a payment

StellarTransaction supports native XLM payments and issued assets. The networkPassphrase must match the network the transaction will be submitted to.
StellarPayment.swift
let xlmPayment = StellarTransaction(
    to: "GRECIPIENT_STELLAR_ADDRESS",
    amount: "10",
    networkPassphrase: StellarNetwork.testnetPassphrase,
    fee: "100",
    timeout: 60
)

let signed = try await paraManager.signTransaction(
    walletId: wallet.id,
    transaction: xlmPayment
)
For issued assets, include the asset code and issuer:
StellarAssetPayment.swift
let usdcPayment = StellarTransaction(
    to: "GRECIPIENT_STELLAR_ADDRESS",
    amount: "5",
    asset: StellarAsset(
        code: "USDC",
        issuer: "GISSUER_STELLAR_ADDRESS"
    ),
    networkPassphrase: StellarNetwork.publicPassphrase
)

Sign serialized XDR

If your backend or Stellar SDK code already builds the transaction, pass the serialized XDR directly.
StellarXDR.swift
let transaction = StellarTransaction(
    serializedXDR: "AAAAAgAAA...",
    networkPassphrase: StellarNetwork.publicPassphrase
)

let result = try await paraManager.signTransaction(
    walletId: wallet.id,
    transaction: transaction
)

Network passphrases

NetworkConstant
Stellar TestnetStellarNetwork.testnetPassphrase
Stellar Public NetworkStellarNetwork.publicPassphrase