iOS SDK

The SDK source code can be found on Github

Install SDK

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'qbWalletSDK'

Import qbWalletSDK

import qbWalletSDK

Get Wallet Address

public static func walletAddress() -> Result<Address, Error> 

switch CryptoWallet.walletAddress()  {
    case .success(let address):
    case .failure(let error):
}

Get Private Key

public static func privateKey() -> Result<PrivateKey, Error>

switch CryptoWallet.privateKey()  {
    case .success(let privateKey):
    case .failure(let error):
}

Get Mnemonic Phrase

public static func mnemonicPhrase() -> Result<Mnemonic, Error> 

switch CryptoWallet.mnemonicPhrase()  {
    case .success(let mnemonic):
    case .failure(let error):
}

Create new Wallet

public static func createWallet() -> Result<Wallet, Error>

switch CryptoWallet.createWallet()  {
    case .success(let wallet): 
    case .failure(let error):
}

Remove existing Wallet

public static func removeWallet() -> Result<(), Error>

switch CryptoWallet.removeWallet() {
    case .success():
    case .failure(let err):
}

Restore Wallet

public static func restoreWallet(mnemonic: Mnemonic) -> Result<Wallet, Error>

switch CryptoWallet.restoreWallet(mnemonic: mnemonic) {
    case .success(let wallet):
    case .failure(let err):
}

Get Balances

public static func getBalances(
    responseHandler: @escaping (Result<TokenBalances, Error>) -> ()
) -> ()

CryptoWallet.getBalances(responseHandler: { result in
    switch result {
        case .success(let balances):
        case .failure(let err):
    }
})

Get Tokens

public static func getTokens(
    responseHandler: @escaping (Result<Tokens, Error>) -> ()
) -> ()

CryptoWallet.getTokens(responseHandler: { result in
    switch result {
        case .success(let tokens):
        case .failure(let err):
    }
})

Get Transactions

public static func getTransactions(
    responseHandler: @escaping (Result<[Transaction], Error>) -> ()
) -> () 

CryptoWallet.getTransactions(responseHandler: { result in
    switch result {
        case .success(let transactions):
        case .failure(let err):
    }
})

Send Transaction

public static func sendTransaction(
    toAddress: Address,
    contractAddress: Address, 
    sendTokenValue: Decimal, 
    responseHandler: @escaping (Result<Hash, Error>) -> ()
) -> ()

CryptoWallet.sendTransaction(
    toAddress: try! Address(address: "0xbBf0458e845E1fd7EEfAd6d5689b13A3E3312510"),
    contractAddress: try! Address(address: "0xf2e71f41e670c2823684ac3dbdf48166084e5af3"),
    sendTokenValue: 1.1,
    responseHandler: { result in
        switch result {
            case .success(let hashTx):
            case .failure(let err):
        }        
    }
)

Entities


public struct Address {
    public let address: String

    public init(address: String) throws {
        // code omitted
    }
}

public struct PrivateKey {
    public let privateKey: String
}

public struct Mnemonic {
    public let phrase: String

    public init(phrase: String) throws {
        // code omitted
    }
}

public struct Wallet {
    public let privateKey: PrivateKey
    public let publicKey: Address
    public let mnemonic: Mnemonic
}

public struct Balances {
    public let privateTokens: [Token]
    public let publicTokens: [Token]
    public let ethBalance: ETHBalance
}

public struct AggregateValue {
    public let USD: String
}

public struct ETHBalance {
    public let balance: String
}

public struct TokenBalances {
    public let transactionCount: Int
    public let balances: Balances
    public let aggValue: AggregateValue
}

public struct Tokens {
    public let privateTokens: [Token]
    public let publicTokens: [Token]
}

public struct Token {
    public let symbol: String
    public let balance: String
    public let contractAddress: Address
}

public struct Transaction {
    public let to: Address
    public let from: Address
    public let contractAddress: Address
    public let timestamp: TimeInterval
    public let token: Token
}

public struct Hash {
    public let hash: String
}

Errors Enum

public enum HTTPErrors: Error {
    case GetRequestFailed(message: String)
    case PostRequestFailed(message: String)
}

public enum JSONParseErrors: Error {
    case ParseTokensFailed
    case ParseBalancesFailed
    case ParseTransactionsFailed
    case ParseSendTxResponseFailed
    case ParseRawTxFailed
    case ParseTokenFailed
}

public enum StorageErrors: Error {
    case MnemonicPhraseEmpty
    case PrivateKeyEmpty
    case WalletAddressEmpty
    case StoreWalletFailed
    case RemoveWalletFailed
}

public enum CryptoErrors: Error {
    case CreateMnemonicFailed
    case CreateWalletFailed
}

public enum ClientEntityErrors: Error {
    case InvalidMnemonicPhrase
    case InvalidWalletAddress
}