Hello, I am one of the developers and maintainers of the Soneso Stellar iOS SDK.
Our SDK is a full featured Swift SDK that facilitates integration with the Stellar Horizon API server and submission of Stellar transactions. My team and I spent the past several weeks writing code for it. It is now ready for beta testing.
If you are an iOS developer and interrested in using a native swift sdk for your iOS app or wallet, check out our sdk.
Here are some examples of typical usage:
1. Keypair Generation
// create a completely new and unique pair of keys.
let keyPair = try! KeyPair.generateRandomKeyPair()
print("Account Id: " + keyPair.accountId)
// GCFXHS4GXL6BVUCXBWXGTITROWLVYXQKQLF4YH5O5JT3YZXCYPAFBJZB
print("Secret Seed: " + keyPair.secretSeed)
// SAV76USXIJOBMEQXPANUOQM6F5LIOTLPDIDVRJBFFE2MDJXG24TAPUU7
2. Check Account
sdk.accounts.getAccountDetails(accountId: accountId) { (response) -> (Void) in
switch response {
case .success(let accountDetails):
// You can check the `balance`, `sequence`, `flags`, `signers`, `data` etc.
for balance in accountDetails.balances {
switch balance.assetType {
case AssetTypeAsString.NATIVE:
print("balance: \(balance.balance) XLM")
default:
print("balance: \(balance.balance) \(balance.assetCode!) issuer: \(balance.assetIssuer!)")
}
}
print("sequence number: \(accountDetails.sequenceNumber)")
for signer in accountDetails.signers {
print("signer public key: \(signer.publicKey)")
}
print("auth required: \(accountDetails.flags.authRequired)")
print("auth revocable: \(accountDetails.flags.authRevocable)")
for (key, value) in accountDetails.data {
print("data key: \(key) value: \(value.base64Decoded() ?? "")")
}
case .failure(let error):
print(error.localizedDescription)
}
}
3. Send Payment
// create the payment operation
let paymentOperation = PaymentOperation(sourceAccount: sourceAccountKeyPair,
destination: destinationAccountKeyPair,
asset: Asset(type: AssetType.ASSET_TYPE_NATIVE)!,
amount: 1.5)
// create the transaction containing the payment operation
let transaction = try Transaction(sourceAccount: accountResponse,
operations: [paymentOperation],
memo: Memo.none,
timeBounds:nil)
// sign the transaction
try transaction.sign(keyPair: sourceAccountKeyPair, network: Network.testnet)
// submit the transaction
try self.sdk.transactions.submitTransaction(transaction: transaction) { (response) -> (Void) in
switch response {
case .success(_):
// ...
case .failure(_):
// ...
}
}
4. Stream Payments
sdk.payments.stream(for: .paymentsForAccount(account: accountId, cursor: nil)).onReceive { (response) -> (Void) in
switch response {
case .open:
break
case .response(let id, let operationResponse):
if let paymentResponse = operationResponse as? PaymentOperationResponse {
switch paymentResponse.assetType {
case AssetTypeAsString.NATIVE:
print("Payment of \(paymentResponse.amount) XLM from \(paymentResponse.sourceAccount) received - id \(id)" )
default:
print("Payment of \(paymentResponse.amount) \(paymentResponse.assetCode!) from \(paymentResponse.sourceAccount) received - id \(id)" )
}
}
case .error(let err):
...
}
}
Github: https://github.com/Soneso/stellar-ios-mac-sdk
Quick Start: https://github.com/Soneso/stellar-ios-mac-sdk#quick-start
Sample app: https://github.com/Block-Equity/stellar-ios-sample-wallet
Testing feedback and all suggestions are welcome. You can create issues here: https://github.com/Soneso/stellar-ios-mac-sdk/issues