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.
Creating Authentication Key
Custodial wallets only
Basic Authentication
Let’s do a basic authentication. In this example, we will use wallet SDK to create an authentication token. First, let’s create ananchor object to work with the anchor you are integrating with. In this example, we will be using a reference anchor implementation with the home domain testanchor.stellar.org
- Kotlin
- TypeScript
- Flutter
- Swift
authKey created earlier:
- Kotlin
- TypeScript
- Flutter
- Swift
authKey.
Home Domain (Optional)
The home domain is the optional parameter for SEP-10 authentication, when a single auth server is shared between multiple domains. Some anchors may require you to provide this argument. The SDK automatically sets thehome_domain parameter in all SEP-10 requests.
Client Domain (Optional)
Non-custodial wallets only
client_domain comes in two parts, the wallet’s client and the wallet’s server implementations. In this setup, we will have an extra authentication key. This key will be stored remotely on the server. Using the SEP-1 info file, the anchor will be able to query this key and verify the signature. As such, the anchor would be able to confirm that the request is coming from your wallet, belonging to wallet’s client_domain.
Client Side
First, let’s implement the client side. In this example we will connect to a remote signer that signs transactions on the endpointhttps://demo-wallet-server.stellar.org/sign for the client domain demo-wallet-server.stellar.org.
- Kotlin
- TypeScript
- Flutter
- Swift
The demo-wallet signing endpoint is not protected for anybody to use. Your production URL must be protected, otherwise anybody could impersonate your wallet’s user.
- Kotlin
- TypeScript
- Flutter
- Swift
- TypeScript
- Kotlin
- Swift
Finally, with the approach above we define the signer and client domain per request. If you want to define it once and use it for every authentication call your application is making, you can do so via changing the configuration:This is particularly useful for integrating with multiple anchors.
Server Side
Next, let’s implement the server side. First, generate a new authentication key that will be used as aclient_domain authentication key.
Next, create a SEP-1 toml file placed under <your domain>/.well-known/stellar.toml with the following content: