StellarSDK

public final class StellarSDK : Sendable

The main entry point for interacting with the Stellar network via the Horizon API.

StellarSDK provides access to all Horizon API services including accounts, transactions, operations, payments, assets, and more. Create an instance configured for your target network (public, testnet, or futurenet) or connect to a custom Horizon server.

The SDK uses the Horizon REST API to query network state and submit transactions. Each instance maintains a connection to a single Horizon server and provides access to specialized service objects for different resource types.

Example:

// Connect to testnet (default)
let sdk = StellarSDK()

// Connect to public network
let publicSdk = StellarSDK.publicNet()

// Connect to futurenet
let futureSdk = StellarSDK.futureNet()

// Connect to custom Horizon URL
let customSdk = StellarSDK(withHorizonUrl: "https://custom-horizon.example.com")

// Query account information
sdk.accounts.getAccountDetails(accountId: "GACCOUNT...") { response in
    switch response {
    case .success(let account):
        print("Balances: \(account.balances)")
    case .failure(let error):
        print("Error: \(error)")
    }
}

// Stream payment events
sdk.payments.stream(for: .paymentsForAccount(account: "GACCOUNT...", cursor: nil))
    .onReceive { payment in
        print("Payment received: \(payment)")
    }

See also:

  • [Network] for network passphrase configuration
  • Stellar developer docs
  • Individual service classes for specific operations