Hinkal Mobile SDK

Getting Started

This guide walks you through integrating the Hinkal Android SDK into your app.

Note

New to the SDK? Start with the Installation guide, then follow the steps below.

Prerequisites

  • The SDK added to your project (Installation)
  • A wallet your app can sign with (EVM, Solana, or TRON)
  • A chain id and token address to work with

Overview

  1. Implement a host wallet so the SDK can sign without holding the key.
  2. Create a client and connect - this derives the shielded identity.
  3. Call operations: deposit, transfer, withdraw, swap.

Basic Setup

Import the SDK

import io.hinkal.mobile.Mobile

Create a client

val client = Mobile.newClient()

Connecting a Wallet

Implement HostWallet so the SDK can read the address and request signatures. The key stays in your wallet.

class WalletHost(private val wallet: YourWalletImplementation) : HostWallet {
    override fun address(): String = wallet.address
    override fun chainID(): Long = wallet.chainId
    override fun personalSign(message: String): String = wallet.personalSign(message)
    override fun sendTransaction(toHex: String, dataHex: String, valueDec: String, gasLimit: Long): String =
        wallet.sendTransaction(toHex, dataHex, valueDec, gasLimit)
    override fun switchChain(chainID: Long) = wallet.switchChain(chainID)
}

Connect - the wallet signs a session message and the SDK derives the shielded identity:

val address = client.connect(WalletHost(yourWallet))
val hinkal = client.hinkal()

Core Operations

Check Balance

val balance = hinkal.getTotalBalance(chainId, signature, address, false, false)

Deposit Tokens

val wei = Mobile.amountToWei(chainId, tokenAddress, "1.0")
val deposit = hinkal.deposit(chainId, "[\"$tokenAddress\"]", "[\"$wei\"]", true, false)

Private Transfer

val transferWei = Mobile.amountToWei(chainId, tokenAddress, "0.5")
val transfer = hinkal.transfer(chainId, "[\"$tokenAddress\"]", "[\"$transferWei\"]",
                               recipientPrivateAddress, tokenAddress, "")

Withdraw Tokens

val withdrawWei = Mobile.amountToWei(chainId, tokenAddress, "0.25")
val withdraw = hinkal.withdraw(chainId, "[\"$tokenAddress\"]", "[\"$withdrawWei\"]",
                               recipientPublicAddress, false, tokenAddress, "")

Swap Tokens

// Get quote first
val quoteJson = hinkal.getEvmSwapPrices(chainId, inWei, inToken, outToken)

// Perform swap
val swap = hinkal.swap(chainId, "[\"$inToken\", \"$outToken\"]", "[\"$inWei\"]",
                       actionID, swapData, inToken, "")