
Comprehensive SDK for building Stellar Network apps: keypair management, transaction building/signing, Horizon REST client, Soroban RPC, smart-contract deployment/invocation, multi-signature and auth workflows.
A comprehensive Kotlin Multiplatform SDK for building applications on the Stellar Network. Write your Stellar integration once in Kotlin and deploy it across JVM (Android, Server), iOS, macOS, and Web (Browser/Node.js) platforms.
| Platform | Status | Crypto Library | Notes |
|---|---|---|---|
| JVM (Android, Server) | Supported | BouncyCastle | Production-ready |
| iOS | Supported | libsodium (native) | iOS 14.0+ |
| macOS | Supported | libsodium (native) | macOS 11.0+ |
| JavaScript (Browser) | Supported | libsodium.js (WebAssembly) | Modern browsers |
| JavaScript (Node.js) | Supported | libsodium.js (WebAssembly) | Node.js 14+ |
The Stellar SDK for Kotlin Multiplatform enables you to:
This SDK uses audited cryptographic libraries on all platforms.
With this SDK, you can create:
See the demo app for examples.
The SDK provides comprehensive Stellar functionality:
Add the SDK as a Maven dependency (recommended for most projects):
// In your module's build.gradle.kts
dependencies {
implementation("com.soneso.stellar:stellar-sdk:1.3.0")
}See Platform-Specific Requirements below and docs/platforms/ for detailed setup instructions
Most platforms require no additional setup. The SDK includes all necessary cryptographic libraries (BouncyCastle for JVM/Android, libsodium.js for JavaScript/Web).
Exception - Native iOS/macOS SwiftUI/UIKit Apps: For native Swift apps where Swift code directly uses SDK types, add libsodium:
https://github.com/jedisct1/swift-sodium
brew install libsodium
See docs/platforms/ for detailed platform-specific instructions.
All cryptographic operations use Kotlin's suspend functions for proper async support across platforms.
import com.soneso.stellar.sdk.KeyPair
import kotlinx.coroutines.runBlocking
suspend fun example() {
// Generate a random keypair
val keypair = KeyPair.random()
println("Account ID: ${keypair.getAccountId()}")
println("Secret Seed: ${keypair.getSecretSeed()?.concatToString()}")
}suspend fun fromSeed() {
val seed = "SDJHRQF4GCMIIKAAAQ6IHY42X73FQFLHUULAPSKKD4DFDM7UXWWCRHBE"
val keypair = KeyPair.fromSecretSeed(seed)
println("Account ID: ${keypair.getAccountId()}")
// Output: GCZHXL5HXQX5ABDM26LHYRCQZ5OJFHLOPLZX47WEBP3V2PF5AVFK2A5D
}import com.soneso.stellar.sdk.horizon.HorizonServer
suspend fun fetchAccountData() {
val server = HorizonServer("https://horizon-testnet.stellar.org")
val accountId = "GCZHXL5HXQX5ABDM26LHYRCQZ5OJFHLOPLZX47WEBP3V2PF5AVFK2A5D"
val account = server.accounts().account(accountId)
println("Sequence: ${account.sequenceNumber}")
println("Balances: ${account.balances}")
}import com.soneso.stellar.sdk.*
import com.soneso.stellar.sdk.horizon.HorizonServer
suspend fun sendPayment() {
val server = HorizonServer("https://horizon-testnet.stellar.org")
val sourceKeypair = KeyPair.fromSecretSeed("SXXX...")
val sourceAccount = server.accounts().account(sourceKeypair.getAccountId())
val destination = "GDUKMGUGDZQK6YHYA5Z6AY2G4XDSZPSZ3SW5UN3ARVMO6QSRDWP5YLEX"
val transaction = TransactionBuilder(sourceAccount, Network.TESTNET)
.setBaseFee(100) // stroops per operation
.addOperation(
PaymentOperation(destination, AssetTypeNative, "10.0")
)
.addMemo(MemoText("Test payment"))
.build()
transaction.sign(sourceKeypair)
val response = server.submitTransaction(transaction.toEnvelopeXdrBase64())
println("Transaction successful: ${response.hash}")
}import com.soneso.stellar.sdk.rpc.SorobanServer
import com.soneso.stellar.sdk.rpc.GetTransactionStatus
suspend fun fetchTransactionData() {
val server = SorobanServer("https://soroban-testnet.stellar.org")
val txHash = "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889"
val response = server.getTransaction(txHash)
when (response.status) {
GetTransactionStatus.SUCCESS -> {
println("Transaction succeeded in ledger ${response.ledger}")
println("Result: ${response.resultXdr}")
}
GetTransactionStatus.FAILED -> {
println("Transaction failed: ${response.resultXdr}")
}
GetTransactionStatus.NOT_FOUND -> {
println("Transaction not yet in ledger")
}
}
server.close()
}The SDK provides a high-level ContractClient API with automatic type conversion:
Simple invocation with auto-execution:
import com.soneso.stellar.sdk.contract.ContractClient
import com.soneso.stellar.sdk.scval.Scv
suspend fun callContract() {
// Load contract spec from network
val client = ContractClient.forContract(
contractId = "CDLZ...",
rpcUrl = "https://soroban-testnet.stellar.org:443",
network = Network.TESTNET
)
// Query with Map-based arguments (auto-executes)
val balance = client.invoke<Long>(
functionName = "balance",
arguments = mapOf("account" to accountAddress),
source = sourceAccount,
signer = null, // No signer for read calls
parseResultXdrFn = { Scv.fromInt128(it).toLong() }
)
println("Balance: $balance")
// Write operation - auto signs and submits
client.invoke<Unit>(
functionName = "transfer",
arguments = mapOf(
"from" to fromAddress,
"to" to toAddress,
"amount" to 1000
),
source = sourceAccount,
signer = keypair, // Required for writes
parseResultXdrFn = null
)
client.close()
}Multi-signature workflows with buildInvoke for manual control:
suspend fun multiSigContractCall() {
val client = ContractClient.forContract(contractId, rpcUrl, Network.TESTNET)
val assembled = client.buildInvoke<String>(...)
// Detect and sign for additional signers
val whoNeedsToSign = assembled.needsNonInvokerSigningBy()
whoNeedsToSign.forEach { assembled.signAuthEntries(getKeypairFor(it)) }
val result = assembled.signAndSubmit(sourceKeypair)
}For deployment examples, authorization patterns, and advanced usage, see the Getting Started Guide and Demo App.
The demo app showcases SDK usage across all platforms with 11 comprehensive features:
See demo/README.md for screenshots and platform-specific build instructions.
This repository includes an Agent Skill that teaches AI coding agents how to use this SDK. See skills/ for installation instructions.
This SDK uses production-ready, audited cryptographic libraries on all platforms:
All implementations provide constant-time operations, proper memory safety, and comprehensive input validation. No experimental or custom cryptography.
See Testing Guide for information on running tests.
We welcome contributions! See CONTRIBUTING.md for guidelines on reporting issues, proposing features, and submitting pull requests.
Licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
A comprehensive Kotlin Multiplatform SDK for building applications on the Stellar Network. Write your Stellar integration once in Kotlin and deploy it across JVM (Android, Server), iOS, macOS, and Web (Browser/Node.js) platforms.
| Platform | Status | Crypto Library | Notes |
|---|---|---|---|
| JVM (Android, Server) | Supported | BouncyCastle | Production-ready |
| iOS | Supported | libsodium (native) | iOS 14.0+ |
| macOS | Supported | libsodium (native) | macOS 11.0+ |
| JavaScript (Browser) | Supported | libsodium.js (WebAssembly) | Modern browsers |
| JavaScript (Node.js) | Supported | libsodium.js (WebAssembly) | Node.js 14+ |
The Stellar SDK for Kotlin Multiplatform enables you to:
This SDK uses audited cryptographic libraries on all platforms.
With this SDK, you can create:
See the demo app for examples.
The SDK provides comprehensive Stellar functionality:
Add the SDK as a Maven dependency (recommended for most projects):
// In your module's build.gradle.kts
dependencies {
implementation("com.soneso.stellar:stellar-sdk:1.3.0")
}See Platform-Specific Requirements below and docs/platforms/ for detailed setup instructions
Most platforms require no additional setup. The SDK includes all necessary cryptographic libraries (BouncyCastle for JVM/Android, libsodium.js for JavaScript/Web).
Exception - Native iOS/macOS SwiftUI/UIKit Apps: For native Swift apps where Swift code directly uses SDK types, add libsodium:
https://github.com/jedisct1/swift-sodium
brew install libsodium
See docs/platforms/ for detailed platform-specific instructions.
All cryptographic operations use Kotlin's suspend functions for proper async support across platforms.
import com.soneso.stellar.sdk.KeyPair
import kotlinx.coroutines.runBlocking
suspend fun example() {
// Generate a random keypair
val keypair = KeyPair.random()
println("Account ID: ${keypair.getAccountId()}")
println("Secret Seed: ${keypair.getSecretSeed()?.concatToString()}")
}suspend fun fromSeed() {
val seed = "SDJHRQF4GCMIIKAAAQ6IHY42X73FQFLHUULAPSKKD4DFDM7UXWWCRHBE"
val keypair = KeyPair.fromSecretSeed(seed)
println("Account ID: ${keypair.getAccountId()}")
// Output: GCZHXL5HXQX5ABDM26LHYRCQZ5OJFHLOPLZX47WEBP3V2PF5AVFK2A5D
}import com.soneso.stellar.sdk.horizon.HorizonServer
suspend fun fetchAccountData() {
val server = HorizonServer("https://horizon-testnet.stellar.org")
val accountId = "GCZHXL5HXQX5ABDM26LHYRCQZ5OJFHLOPLZX47WEBP3V2PF5AVFK2A5D"
val account = server.accounts().account(accountId)
println("Sequence: ${account.sequenceNumber}")
println("Balances: ${account.balances}")
}import com.soneso.stellar.sdk.*
import com.soneso.stellar.sdk.horizon.HorizonServer
suspend fun sendPayment() {
val server = HorizonServer("https://horizon-testnet.stellar.org")
val sourceKeypair = KeyPair.fromSecretSeed("SXXX...")
val sourceAccount = server.accounts().account(sourceKeypair.getAccountId())
val destination = "GDUKMGUGDZQK6YHYA5Z6AY2G4XDSZPSZ3SW5UN3ARVMO6QSRDWP5YLEX"
val transaction = TransactionBuilder(sourceAccount, Network.TESTNET)
.setBaseFee(100) // stroops per operation
.addOperation(
PaymentOperation(destination, AssetTypeNative, "10.0")
)
.addMemo(MemoText("Test payment"))
.build()
transaction.sign(sourceKeypair)
val response = server.submitTransaction(transaction.toEnvelopeXdrBase64())
println("Transaction successful: ${response.hash}")
}import com.soneso.stellar.sdk.rpc.SorobanServer
import com.soneso.stellar.sdk.rpc.GetTransactionStatus
suspend fun fetchTransactionData() {
val server = SorobanServer("https://soroban-testnet.stellar.org")
val txHash = "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889"
val response = server.getTransaction(txHash)
when (response.status) {
GetTransactionStatus.SUCCESS -> {
println("Transaction succeeded in ledger ${response.ledger}")
println("Result: ${response.resultXdr}")
}
GetTransactionStatus.FAILED -> {
println("Transaction failed: ${response.resultXdr}")
}
GetTransactionStatus.NOT_FOUND -> {
println("Transaction not yet in ledger")
}
}
server.close()
}The SDK provides a high-level ContractClient API with automatic type conversion:
Simple invocation with auto-execution:
import com.soneso.stellar.sdk.contract.ContractClient
import com.soneso.stellar.sdk.scval.Scv
suspend fun callContract() {
// Load contract spec from network
val client = ContractClient.forContract(
contractId = "CDLZ...",
rpcUrl = "https://soroban-testnet.stellar.org:443",
network = Network.TESTNET
)
// Query with Map-based arguments (auto-executes)
val balance = client.invoke<Long>(
functionName = "balance",
arguments = mapOf("account" to accountAddress),
source = sourceAccount,
signer = null, // No signer for read calls
parseResultXdrFn = { Scv.fromInt128(it).toLong() }
)
println("Balance: $balance")
// Write operation - auto signs and submits
client.invoke<Unit>(
functionName = "transfer",
arguments = mapOf(
"from" to fromAddress,
"to" to toAddress,
"amount" to 1000
),
source = sourceAccount,
signer = keypair, // Required for writes
parseResultXdrFn = null
)
client.close()
}Multi-signature workflows with buildInvoke for manual control:
suspend fun multiSigContractCall() {
val client = ContractClient.forContract(contractId, rpcUrl, Network.TESTNET)
val assembled = client.buildInvoke<String>(...)
// Detect and sign for additional signers
val whoNeedsToSign = assembled.needsNonInvokerSigningBy()
whoNeedsToSign.forEach { assembled.signAuthEntries(getKeypairFor(it)) }
val result = assembled.signAndSubmit(sourceKeypair)
}For deployment examples, authorization patterns, and advanced usage, see the Getting Started Guide and Demo App.
The demo app showcases SDK usage across all platforms with 11 comprehensive features:
See demo/README.md for screenshots and platform-specific build instructions.
This repository includes an Agent Skill that teaches AI coding agents how to use this SDK. See skills/ for installation instructions.
This SDK uses production-ready, audited cryptographic libraries on all platforms:
All implementations provide constant-time operations, proper memory safety, and comprehensive input validation. No experimental or custom cryptography.
See Testing Guide for information on running tests.
We welcome contributions! See CONTRIBUTING.md for guidelines on reporting issues, proposing features, and submitting pull requests.
Licensed under the Apache License, Version 2.0. See LICENSE for the full license text.