Skip to content

Soneso/stellar-ios-mac-sdk

GitHub release Tests codecov Ask DeepWiki

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.

Installation

Swift Package Manager

.package(name: "stellarsdk", url: "git@github.com:Soneso/stellar-ios-mac-sdk.git", from: "3.4.6"),

CocoaPods

pod 'stellar-ios-mac-sdk', '~> 3.4.6'

Requires iOS 13+, macOS 10.15+, Swift 5.7+.

Quick examples

Send a payment

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)

Trust an asset

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)

Call a smart contract

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.

Agent Skill

This repository includes an Agent Skill that teaches AI coding agents how to use this SDK. See skills/ for installation instructions.

Documentation

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.

API reference

Soroban Smart Wallets (Passkey) support

We are working on integrating passkey support for Soroban Smart Wallets into this SDK. In the meantime, we provide an experimental Passkey Kit: SwiftPasskeyKit.

Compatibility

Sample

This SDK is used by the open source LOBSTR Vault (source) and the LOBSTR Wallet.

Feedback

If you're using this SDK, feedback helps improve it:

Contributing

See CONTRIBUTING.md for guidelines.

License

Apache 2.0. See LICENSE.

About

Stellar SDK for iOS & macOS - Swift, Stellar, Horizon, Soneso

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors