This guide is available on four different programming languages: Typescript, Kotlin, Flutter (Dart) and Swift. You can change the shown version on each page via the buttons above.
Installation
First, you need to add the SDK dependency to your project.- TypeScript
- Kotlin
- Flutter
- Swift
Working with the SDK
Let’s start with the main class that provides all SDK functionality. It’s advised to have a singleton wallet object shared across the application. Creating a wallet with a default configuration connected to Stellar’s Testnet is simple:- Kotlin
- TypeScript
- Flutter
- Swift
- Kotlin
- TypeScript
- Flutter
- Swift
Configuring the Client
- Kotlin
- TypeScript
- Flutter
The Kotlin wallet SDK uses the ktor client for all network requests (excluding Horizon, where the Stellar SDK’s HTTP client is used). Currently, the okhttp engine is configured to be used with the client. You can read more about how to configure the ktor client here.For example, the client can be globally configured:This Kotlin code will set the connect timeout to ten seconds via the okhttp configuration and also installs the retry plugin. You can also specify client configuration for specific wallet SDK classes.For example, to change connect timeout when connecting to some anchor server:
Closing Resources
After the wallet class is no longer used, it’s necessary to close all clients used by it. While in some applications it may not be required (e.g. the wallet lives for the whole lifetime of the application), in other cases it can be required. If your wallet class is short-lived, it’s recommended to close client resources using a close function:Stellar Basics
The wallet SDK provides some extra functionality on top of the existing Horizon SDK. For interaction with the Stellar network, the wallet SDK covers only the basics used in a typical wallet flow. For more advanced use cases, the underlying Horizon SDK should be used instead. To interact with the Horizon instance configured in the previous steps, simply do:- Kotlin
- TypeScript
- Flutter
- Swift
Default configuration connects to the public Stellar Horizon instance. You can change this behavior as described above.
Anchor Basics
Primary use of the SDK is to provide an easy way to connect to anchors via sets of protocols known as SEPs. Let’s look into connecting to the Stellar test anchor:- Kotlin
- TypeScript
- Flutter
- Swift
- TypeScript
If the anchor home domain uses http, then you need to set the This can only be used on Testnet.
allowHttp flag when creating the anchor:- Kotlin
- TypeScript
- Flutter
- Swift
- SEP-1: Stellar Info File as shown above
- SEP-10: explored on Stellar Authentication section
- SEP-24: explored on Hosted Deposit and Withdrawal section
- SEP-6: explored on Programmatic Deposit and Withdrawal section
- SEP-12: explored on Providing KYC info subsection
- SEP-38: explored on Quote section