Build and sign Stellar transactions, query Horizon, and interact with Soroban smart contracts via RPC. Communicate with anchors and external services using built-in support for 17 SEPs.
.package(name: "stellarsdk", url: "git@github.com:Soneso/stellar-ios-mac-sdk.git", from: "3.4.6"),pod 'stellar-ios-mac-sdk', '~> 3.4.6'Requires iOS 13+, macOS 10.15+, Swift 5.7+.
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:
let client = try await SorobanClient.forClientOptions(
options: ClientOptions(
sourceAccountKeyPair: keyPair,
contractId: "CABC...",
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 |
| SEPs | Anchor integration, authentication, KYC, etc. |
We are working on integrating passkey support for Soroban Smart Wallets into this SDK. In the meantime, we provide an experimental Passkey Kit: SwiftPasskeyKit.
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.