Skip to main content
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.

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:
The wallet instance can be further configured. For example, to connect to the public network:
There is one more available configuration for a wallet that allows it to configure internal logic of the SDK. For example, to test with local servers on an HTTP protocol, HTTP can be manually enabled.

Configuring the Client

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:
This example will create a Stellar class that manages the connection to Horizon service.
Default configuration connects to the public Stellar Horizon instance. You can change this behavior as described above.
You can read more about working with the Stellar network in the respective section.

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:
If the anchor home domain uses http, then you need to set the allowHttp flag when creating the anchor:
This can only be used on Testnet.
And the most basic interaction of fetching a SEP-1: Stellar Info File:
Below you can find all the SEPs the anchor class currently supports: Besides the SEPs supported by the anchor class the wallet SDK also has support for the SEP-7 protocol which is explored on URI Scheme to facilitate delegated signing section.