Build and sign Stellar transactions, query Horizon, and interact with Soroban smart contracts via RPC. Communicate with anchors and external services using the built-in SEP protocol support.
Add the SDK with Swift Package Manager:
.package(name: "stellarsdk", url: "git@github.com:Soneso/stellar-ios-mac-sdk.git", from: "3.12.0"),Requires iOS 15+, macOS 12+, Xcode 16+ (Swift 6 toolchain). Your app can build in Swift 5 or Swift 6 language mode.
Transfer XLM between accounts:
let paymentOp = PaymentOperation(sourceAccountId: nil,
destinationAccountId: receiverId,
asset: Asset(type: AssetType.ASSET_TYPE_NATIVE)!,
amount: 100)
let transaction = try Transaction(sourceAccount: senderAccount,
operations: [paymentOp],
memo: Memo.none)
try transaction.sign(keyPair: senderKeyPair, network: .testnet)
let response = await sdk.transactions.submitTransaction(transaction: transaction)Enable your account to receive a token (like USDC):
let usdc = ChangeTrustAsset(canonicalForm: "USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5")!
let trustOp = ChangeTrustOperation(sourceAccountId: nil,
asset: usdc,
limit: nil)
let transaction = try Transaction(sourceAccount: account,
operations: [trustOp],
memo: Memo.none)
try transaction.sign(keyPair: accountKeyPair, network: .testnet)
let response = await sdk.transactions.submitTransaction(transaction: transaction)Invoke a Soroban contract method:
import stellarsdk
// keyPair: your funded account's KeyPair (see "Create an account" above)
let client = try await SorobanClient.forClientOptions(
options: ClientOptions(
sourceAccountKeyPair: keyPair,
contractId: "CB3FU6M3TOAGRBLN5WDLXL6A7VR5SSRGULMXQQOABNMPS25YRJ4CN5VV", // your deployed contract's id
network: .testnet,
rpcUrl: "https://soroban-testnet.stellar.org",
enableServerLogging: false
)
)
let result = try await client.invokeMethod(name: "hello", args: [SCValXDR.symbol("World")])For complete walkthroughs, see the documentation.
This repository includes an Agent Skill that teaches AI coding agents how to use this SDK. See skills/ for installation instructions.
| Guide | Description |
|---|---|
| Quick start | Your first transaction in 15 minutes |
| Getting started | Keys, accounts, and fundamentals |
| SDK usage | Transactions, operations, Horizon queries, streaming |
| Soroban | Smart contract deployment and interaction |
| Smart Accounts | OpenZeppelin smart account support: passkeys, multi-signer authorization, context rules, policies |
| SEPs | Anchor integration, authentication, KYC, etc. |
The SDK supports OpenZeppelin smart accounts on Stellar — passkey/WebAuthn authentication, multi-signer authorization, context rules, and policies. See the Smart Accounts documentation and the demo app.
This SDK is used by the open source LOBSTR Vault (source) and the LOBSTR Wallet.
If you're using this SDK, feedback helps improve it:
See CONTRIBUTING.md for guidelines.
Apache 2.0. See LICENSE.