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.
Create Recoverable Account
First, let’s create an account key, a device key, and a recovery key that will be attached to the account.- TypeScript
- Kotlin
- Flutter
- Swift
accountKp is the wallet’s main account. The deviceKp we will be adding to the wallet as a signer so a device (eg. a mobile device a wallet is hosted on) can take control of the account. And the recoveryKp will be used to identify the key with the recovery servers.
Next, let’s identify the recovery servers and create our recovery object:
- TypeScript
- Kotlin
- Flutter
- Swift
- TypeScript
- Kotlin
- Flutter
- Swift
- TypeScript
- Kotlin
- Flutter
- Swift
- Set
deviceKpas the primary account key. Please note that the master key belonging toaccountKpwill be locked.deviceKpshould be used as a primary signer instead. - Set all operation thresholds to 10. You can read more about threshold in the documentation
- Use identities that were defined earlier on both servers. (That means, both server will accept SEP-10 authentication via
recoveryKpas an auth method) - Set device key weight to 10, and recovery server weight to 5. Given these account thresholds, both servers must be used to recover the account, as transaction signed by one will only have weight of 5, which is not sufficient to change account key.
- TypeScript
- Kotlin
- Flutter
- Swift
Get Account Info
You can fetch account info from one or more servers. To do so, first we need to authenticate with a recovery server using the SEP-10 authentication method:- TypeScript
- Kotlin
- Flutter
- Swift
- TypeScript
- Kotlin
- Flutter
- Swift
- TypeScript
- Kotlin
- Flutter
- Swift
Recover Wallet
Let’s say we’ve lost our device key and need to recover our wallet. First, we need to authenticate with both recovery servers:- TypeScript
- Kotlin
- Flutter
- Swift
recoverableWallet.signers), or via fetching account info from recovery servers.
- TypeScript
- Kotlin
- Flutter
- Swift
- TypeScript
- Kotlin
- Flutter
- Swift
- It’s the only signer that’s not in
serverAuth. - All signers in
serverAuthhave the same weight, and the potential signer is the only one with a different weight.
The account created above will match the first criteria. If a 2-3 schema were used, then the second criteria would match. (In a 2-3 schema, 3 servers are used and 2 of them are enough to recover the key. This is a recommended approach.)You can also use more low-level
signWithRecoveryServers functions to sign arbitrary transactions.- TypeScript
- Kotlin
- Flutter
- Swift