Android SDK

The SDK source code can be found on Github

With qbWallet SDK you can create new wallet or restore existing one. Get wallet balances, tokens and perform transactions.

Install SDK

implementation 'com.qiibee:qb-wallet-sdk:0.1.0'

Import qbWalletSDK

import com.qiibee.wallet_sdk.client.CryptoWallet
import com.qiibee.wallet_sdk.client.Mnemonic
import com.qiibee.wallet_sdk.client.Address
import com.qiibee.wallet_sdk.util.Failure
import com.qiibee.wallet_sdk.util.Success

Intialize Context onCreate

CryptoWallet.initialize(this)

Get Wallet Address

fun walletAddress(): Result<Address, Exception>

when (val result = CryptoWallet.walletAddress()) {
    is Success -> { result.value.address }
    is Failure -> { result.reason.message }
}

Get Private Key

fun privateKey(): Result<PrivateKey, Exception>

when (val result = CryptoWallet.privateKey()) {
    is Success -> { result.value.privateKey }
    is Failure -> { result.reason.message }
}

Get Mnemonic Phrase

fun mnemonicPhrase(): Result<Mnemonic, Exception> 

when (val result = CryptoWallet.mnemonicPhrase()) {
    is Success -> { result.value.phrase }
    is Failure -> { result.reason.message }
}

Create new Wallet

fun createWallet(): Result<Address, Exception>

when (val result = CryptoWallet.createWallet()) {
    is Success -> { result.value.address }
    is Failure -> { result.reason.message }
}

Remove existing Wallet

fun removeWallet(): Result<Unit, Exception>

when (val result = CryptoWallet.removeWallet()) {
    is Success -> { }
    is Failure -> { result.reason.message }
}

Restore Wallet

fun restoreWallet(mnemonic: Mnemonic): Result<Address, Exception>

when (val result = CryptoWallet.restoreWallet(validMnemonic)) {
    is Success -> { result.value.address }
    is Failure -> { result.reason.message }
}

Get Balances

fun getBalances(responseHandler: (result: Result<TokenBalances, Exception>) -> Unit)

CryptoWallet.getBalances {
    when (it) {
        is Success -> { it.value.balances }
        is Failure -> { it.reason.message }
    }
}

Get Tokens

fun getTokens(responseHandler: (result: Result<Tokens, Exception>) -> Unit)

CryptoWallet.getTokens {
    when (it) {
        is Success -> {
            it.value.publicTokens
            it.value.privateTokens
        }
        is Failure -> { it.reason.message }
    }
}

Get Transactions

fun getTransactions(responseHandler: (result: Result<List<Transaction>, Exception>) -> Unit)

CryptoWallet.getTransactions {
    when (it) {
        is Success -> {
             for (tx in it.value) {
                tx.contractAddress 
                tx.from
            }
        }
        is Failure -> { it.reason.message }
    }
}

Send Transaction

fun sendTransaction(
    toAddress: Address,
    contractAddress: Address,
    sendTokenValue: BigDecimal,
    responseHandler: (result: Result<Hash, Exception>) -> Unit
)

val toAddress = Address("0x6d5p603bnE331f045bft74Ee84AdjEj6j9b1251f")
val contractAddress = Address("0xf2e71f41e670c2823684ac3dbdf48166084e5af3")
val value = BigDecimal(3.4)

CryptoWallet.sendTransaction(toAddress, contractAddress, value) {
    when (it) {
        is Success -> { it.value }
        is Failure -> { it.reason.message }
    }
}

Entities


data class Address(val address: String)

data class TokenBalances(
    val transactionCount: Int,
    val balances: Balances,
    val aggValue: AggregateValue
)

data class AggregateValue(val USD: BigDecimal)
data class ETHBalance(val balance: BigDecimal)

data class Tokens (
    val privateTokens: List<Token>,
    val publicTokens: List<Token>
)

data class Token (
    val symbol: String,
    val balance: BigDecimal,
    val contractAddress: Address
)

data class Balances(
    val privateTokens: List<Token>,
    val publicTokens: List<Token>,
    val ethBalance: ETHBalance
)

data class Transaction(
    val to: Address,
    val from: Address,
    val contractAddress: Address,
    val timestamp: Timestamp,
    val token: Token
)

data class Mnemonic(val phrase: String)

data class PrivateKey(val privateKey: String)

Error Classes

class InvalidWalletAddress(address: String)
class MnemonicCreationFailed(error: String)
class WalletNotFound
class WalletCreationFailed(error: String)
class InvalidMnemonicPhrase(phrase: String)
class InvalidPrivateKey(key: String)
class WalletSDKNotInitialized
class RemoveWalletFailed(error: String)
class StoreWalletDetailsFailed(error: String)

class GetTokenBalancesFailed(error: String)
class GetTokensFailed(error: String)
class GetRawTransactionFailed(error: String)
class GetTransactionsFailed(error: String)
class SendTransactionFailed(error: String)