Mnemonic

A mnemonic is a human readable list of words that generates a master seed, that in turn, generates wallet accounts for users. It is critical that a mnemonic must be backed-up by the user, as soon as it is generated. If the user’s account is deleted from their device, or if the device is lost, the mnemonic is not recoverable! It is the key to accessing a user’s wallet accounts. We are working on cloud-backup using the iOS/Android keystore for users with smaller account balances.

Generate a Mnemonic seed

Creates a random mnemonic string. Returned string can be displayed to the user for backup. After calling createMnemonic, call createAccount to create the first account using this mnemonic.

Abstrakt.shared.createMnemonic() -> String

Import Mnemonic

This function imports an mnemonic to the device. The user can type in their mnemonic and recover previously generated accounts or import accounts from another device. Two Cases:

  1. The user already has accounts previously created from this menmonic in SDK. (function getMyAccounts returns accounts)
    • In this case, private keys of existing accounts are automatically generated using the imported menmonic.
  2. The user does not have existing accounts generated earlier.
    • In this case, nickName and blockchainNetwork can be set to create first account. If unset, defaults will be used to create first account.

Note: multiple mnemonics supported.

ParameterDescription
mnemonicmnemonic string to import
nickNameoptional name of first account created using mnemonic. Both blockchainNetwork and nickName have to be specifed or either.
blockchainNetworkoptional blockchain network of first account created.
ReturnDescription
booleanreturns true = success or false = failed
// Case 1.  Try importing before asking for user input for nickName and blockchainNetwork
Abstrakt.shared.importMnemonic(mnemonic: String) -> Int
// Case 2.  Import mnemonic and create account
Abstrakt.shared.importMnemonic(mnemonic: String, nickName: String, blockchainNetwork: BlockchainNetwork, completion: @escaping (CompletionError?) -> Void)

Check if Mnemonic is valid

Abstrakt.shared.isValidMnemonic(mnemonic: String) -> Bool

Get Mnemonic

This function returns generated/imported menmonic encrypted on the device. It can be displayed to the user for backing up.

Abstrakt.shared.getMnemonic(completion: @escaping (String) -> Void)

Check if specified account has private key encrypted on device

Abstrakt.shared.hasPrivateKey(blockchainNetwork: BlockchainNetwork, accountAddress: String) -> Bool

Check if specified account has menmonic encrypted on device

Abstrakt.shared.hasMnemonic(blockchainNetwork: BlockchainNetwork, accountAddress: String) -> Bool

Cloud backup (work in progress…)

This function will enable you to encrypt the user generated mnenomnic with a password and store it to the apple keychain.

Recover cloud backup (work in progress…)

Once a mnenomic is encrypted and backuped to the user’s apple keychain, it can be recovered automatcially on future logins.