QuickStart

This sample code demonstrates how to autheticate a user and call SDK functions onces the framework is setup.

Note: Abstrakt.shared is used to access the Abstrakt framework as singleton. Currently all functions need to be accessed using 'shared’

import UIKit
import AbstraktSDK

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        // Step 1: Authenticate user to abstrakt services 
        Abstrakt.shared.authenticateWithEmailAndPassword(email: "daniel@testgmail.com", password: "testingpassword", completion: { (status) in
            if status == "success" {
                print("Authenticated successfully")
            } else {
                print("failed to authenticate")
            }
        }

        // Step 2: Generate new mnenonic seed for user. User must save the mnemonic. Mnemonic is required to recover account.
        let generatedMnemonic = Abstrakt.shared.createMnemonic()

        // Step 3: Generate ethereum account from mnemonic  
        let nickName = "AccountName"
        Abstrakt.shared.createAccount(nickName: nickName, blockchainNetwork: BlockchainNetwork.EthMainnet)  { (status) in
            if status {
                print("Account created successfully")
            } else {
                print("Failed to create account")
            }
        }

        // Step 4: Check your created accounts
        Abstrakt.shared.getMyAccounts(isTestnetEnabled: false) { (accounts) in
            print("account count \(accounts.count)")                
        }

        // Deletes all local data including user mnemonic, accounts and cached data. Make sure user has backed up mnemonic before logout
        Abstrakt.shared.logout();    
    }
}