/stellar-ios-mac-sdk
Guides Stellar blockchain development in Swift using stellar-ios-mac-sdk. Use when generating Swift code for transaction building, signing, Horizon API queries, Soroban RPC, smart contract deployment and invocation, smart accounts (OpenZeppelin) with passkey / WebAuthn
$ npx -y skills add soneso/stellar-ios-mac-sdk --skill stellar-ios-mac-sdk --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/stellar-ios-mac-sdk
Context preview
The summary Claude sees to decide when to auto-load this skill.
Guides Stellar blockchain development in Swift using stellar-ios-mac-sdk. Use when generating Swift code for transaction building, signing, Horizon API queries, Soroban RPC, smart contract deployment and invocation, smart accounts (OpenZeppelin) with passkey / WebAuthn
SKILL.md
stellar-ios-mac-sdk.SKILL.mdname: stellar-ios-mac-sdk
description: Guides Stellar blockchain development in Swift using stellar-ios-mac-sdk. Use when generating Swift code for transaction building, signing, Horizon API queries, Soroban RPC, smart contract deployment and invocation, smart accounts (OpenZeppelin) with passkey / WebAuthn authentication, XDR encoding/decoding, and SEP protocol integration. Network APIs use Swift async/await; Horizon streaming is callback-based. Triggers when the developer mentions Stellar, blockchain, passkey, smart wallet, or biometric signing on iOS or macOS. Full Swift 6 strict concurrency support (all types Sendable).
license: Apache 2.0
compatibility: Requires Xcode 16+ (Swift 6 toolchain), iOS 15+, macOS 12+. Zero external dependencies.
metadata:
version: "1.10.0"
sdk_version: "3.14.0"
last_updated: "2026-10-24"
Stellar SDK for iOS & Mac
Overview
The Stellar iOS/Mac SDK (`stellarsdk`) is a native Swift library for building Stellar applications on iOS 15+ and macOS 12+. It covers the Horizon API, the Soroban RPC API, and the SEP protocol suite. Network APIs use Swift async/await; the Horizon streaming endpoints are callback-based (`onReceive` closures on retained stream items); builders, encoders, and other utilities are synchronous. The SDK compiles with Swift 6 strict concurrency and has zero external dependencies.
**Module name:** `stellarsdk` (always lowercase in import statements)
Installation
Add the SDK with Swift Package Manager:
.package(name: "stellarsdk", url: "git@github.com:Soneso/stellar-ios-mac-sdk.git", from: "3.14.0")
> All code examples below assume `import stellarsdk`. > > If you can't find a constructor or method signature in this file or the topic references, grep `references/api_reference.md` — it has all public class/method signatures.
1. Stellar Basics
Fundamental Stellar concepts and SDK patterns.
Keys and KeyPairs
// Generate new keypair
let keyPair = try KeyPair.generateRandomKeyPair()
let accountId = keyPair.accountId // G-address
guard let secretSeed = keyPair.secretSeed else {
throw StellarSDKError.invalidArgument(message: "Failed to get secret seed")
}
// WARNING: Store secretSeed securely (iOS Keychain). Never log or hardcode it.// From existing seed (seed: the "S..." secret seed string, loaded from secure storage)
let keyPair = try KeyPair(secretSeed: seed)
let publicOnly = try KeyPair(accountId: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ") // public-only, cannot sign
Accounts
// Fund testnet account (FriendBot)
let keyPair = try KeyPair.generateRandomKeyPair()
let sdk = StellarSDK.testNet()
let responseEnum = await sdk.accounts.createTestAccount(accountId: keyPair.accountId)
// Query account
let responseEnum = await sdk.accounts.getAccountDetails(accountId: accountId)
switch responseEnum {
case .success(let accountResponse):
print("Sequence: \(accountResponse.sequenceNumber)")
print("Subentry count: \(accountResponse.subentryCount)") // Trustlines, offers, data entries
for balance in accountResponse.balances {
print("Asset: \(balance.assetType), Balance: \(balance.balance)")
// WRONG: balance.assetType == AssetType.ASSET_TYPE_NATIVE (comparing String to Int32)
// CORRECT: balance.assetType == "native" (response fields are strings)
if balance.assetType == "native" {
print(" → Native XLM balance")
} else if balance.assetType == "credit_alphanum4" || balance.assetType == "credit_alphanum12" {
print(" → Custom asset: \(balance.assetCode ?? ""):\(balance.assetIssuer ?? "")")
}
}
case .failure(let error):
print("Error: \(error)")
}Assets
// Native XLM
let xlm = Asset(type: AssetType.ASSET_TYPE_NATIVE)!
// Issued asset (4-char code)
let issuerKeyPair = try KeyPair(accountId: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ") // asset issuer
let usdc = Asset(type: AssetType.ASSET_TYPE_CREDIT_ALPHANUM4,
code: "USDC",
issuer: issuerKeyPair)!
// From canonical form "CODE:ISSUER" — failable, returns nil for a malformed string
if let asset = Asset(canonicalForm: "USDC:GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ") {
print(asset.toCanonicalForm())
}Networks
// Pre-configured: Network.testnet, Network.public, Network.futurenet
let testnetSdk = StellarSDK.testNet()
let publicSdk = StellarSDK.publicNet()
// Custom Horizon URL
let customSdk = StellarSDK(withHorizonUrl: "https://my-horizon.example.com")
2. Horizon API - Fetching Data
Query patterns for retrieving blockchain data. All queries return result enums (`.success`/`.failure`).
Query Accounts & Transactions
let sdk = StellarSDK.testNet()
// Account details
let accountEnum = await sdk.accounts.getAccountDetails(accountId: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ")
// Transactions for account
let txEnum = await sdk.transactions.getTransactions(
forAccount: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ",
from: nil,
order: .descending,
limit: 10
)
// Pagination: use cursor from last record's pagingToken
switch txEnum {
case .success(let page):
if let lastRecord = page.records.last {
let nextPage = await sdk.transactions.getTransactions(
forAccount: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ",
from: lastRecord.pagingToken,
order: .descending,
limit: 10
)
}
case .failure(let error):
print("Error: \(error)")
}For the full Horizon endpoint coverage, advanced queries, and memo inspection: [Horizon API Reference](./references/horizon_api.md)
3. Horizon API - Streaming
Real-time update patterns using Server-Sent Events. **You must hold a strong reference** to the stream item or it will close immediately.
class PaymentMo
Read more
name: stellar-ios-mac-sdk description: Guides Stellar blockchain development in Swift using stellar-ios-mac-sdk. Use when generating Swift code for transaction building, signing, Horizon API queries, Soroban RPC, smart contract deployment and invocation, smart accounts (OpenZeppelin) with passkey / WebAuthn authentication, XDR encoding/decoding, and SEP protocol integration. Network APIs use Swift async/await; Horizon streaming is callback-based. Triggers when the developer mentions Stellar, blockchain, passkey, smart wallet, or biometric signing on iOS or macOS. Full Swift 6 strict concurrency support (all types Sendable). license: Apache 2.0 compatibility: Requires Xcode 16+ (Swift 6 toolchain), iOS 15+, macOS 12+. Zero external dependencies. metadata: version: "1.10.0" sdk_version: "3.14.0" last_updated: "2026-10-24"
Stellar SDK for iOS & Mac
Overview
The Stellar iOS/Mac SDK (`stellarsdk`) is a native Swift library for building Stellar applications on iOS 15+ and macOS 12+. It covers the Horizon API, the Soroban RPC API, and the SEP protocol suite. Network APIs use Swift async/await; the Horizon streaming endpoints are callback-based (`onReceive` closures on retained stream items); builders, encoders, and other utilities are synchronous. The SDK compiles with Swift 6 strict concurrency and has zero external dependencies.
**Module name:** `stellarsdk` (always lowercase in import statements)
Installation
Add the SDK with Swift Package Manager:
.package(name: "stellarsdk", url: "git@github.com:Soneso/stellar-ios-mac-sdk.git", from: "3.14.0")
> All code examples below assume `import stellarsdk`. > > If you can't find a constructor or method signature in this file or the topic references, grep `references/api_reference.md` — it has all public class/method signatures.
1. Stellar Basics
Fundamental Stellar concepts and SDK patterns.
Keys and KeyPairs
// Generate new keypair
let keyPair = try KeyPair.generateRandomKeyPair()
let accountId = keyPair.accountId // G-address
guard let secretSeed = keyPair.secretSeed else {
throw StellarSDKError.invalidArgument(message: "Failed to get secret seed")
}
// WARNING: Store secretSeed securely (iOS Keychain). Never log or hardcode it.// From existing seed (seed: the "S..." secret seed string, loaded from secure storage) let keyPair = try KeyPair(secretSeed: seed) let publicOnly = try KeyPair(accountId: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ") // public-only, cannot sign
Accounts
// Fund testnet account (FriendBot)
let keyPair = try KeyPair.generateRandomKeyPair()
let sdk = StellarSDK.testNet()
let responseEnum = await sdk.accounts.createTestAccount(accountId: keyPair.accountId)
// Query account
let responseEnum = await sdk.accounts.getAccountDetails(accountId: accountId)
switch responseEnum {
case .success(let accountResponse):
print("Sequence: \(accountResponse.sequenceNumber)")
print("Subentry count: \(accountResponse.subentryCount)") // Trustlines, offers, data entries
for balance in accountResponse.balances {
print("Asset: \(balance.assetType), Balance: \(balance.balance)")
// WRONG: balance.assetType == AssetType.ASSET_TYPE_NATIVE (comparing String to Int32)
// CORRECT: balance.assetType == "native" (response fields are strings)
if balance.assetType == "native" {
print(" → Native XLM balance")
} else if balance.assetType == "credit_alphanum4" || balance.assetType == "credit_alphanum12" {
print(" → Custom asset: \(balance.assetCode ?? ""):\(balance.assetIssuer ?? "")")
}
}
case .failure(let error):
print("Error: \(error)")
}Assets
// Native XLM
let xlm = Asset(type: AssetType.ASSET_TYPE_NATIVE)!
// Issued asset (4-char code)
let issuerKeyPair = try KeyPair(accountId: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ") // asset issuer
let usdc = Asset(type: AssetType.ASSET_TYPE_CREDIT_ALPHANUM4,
code: "USDC",
issuer: issuerKeyPair)!
// From canonical form "CODE:ISSUER" — failable, returns nil for a malformed string
if let asset = Asset(canonicalForm: "USDC:GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ") {
print(asset.toCanonicalForm())
}Networks
// Pre-configured: Network.testnet, Network.public, Network.futurenet let testnetSdk = StellarSDK.testNet() let publicSdk = StellarSDK.publicNet() // Custom Horizon URL let customSdk = StellarSDK(withHorizonUrl: "https://my-horizon.example.com")
2. Horizon API - Fetching Data
Query patterns for retrieving blockchain data. All queries return result enums (`.success`/`.failure`).
Query Accounts & Transactions
let sdk = StellarSDK.testNet()
// Account details
let accountEnum = await sdk.accounts.getAccountDetails(accountId: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ")
// Transactions for account
let txEnum = await sdk.transactions.getTransactions(
forAccount: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ",
from: nil,
order: .descending,
limit: 10
)
// Pagination: use cursor from last record's pagingToken
switch txEnum {
case .success(let page):
if let lastRecord = page.records.last {
let nextPage = await sdk.transactions.getTransactions(
forAccount: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ",
from: lastRecord.pagingToken,
order: .descending,
limit: 10
)
}
case .failure(let error):
print("Error: \(error)")
}For the full Horizon endpoint coverage, advanced queries, and memo inspection: [Horizon API Reference](./references/horizon_api.md)
3. Horizon API - Streaming
Real-time update patterns using Server-Sent Events. **You must hold a strong reference** to the stream item or it will close immediately.
class PaymentMo
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.

