Hinkal Mobile SDK
Quickstart
Integrate private token transfers into your Android app in a few minutes.
Note
This quickstart gets you running fast with minimal explanation. For a detailed walkthrough see Android Getting Started; for the full method list see Android API Reference.
Installation
The SDK is published to Maven Central. Add to your build.gradle.kts:
dependencies {
implementation("io.hinkal:hinkal-android:0.1.3")
}import io.hinkal.mobile.MobileQuick Example
1. Implement the host 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)
}2. Connect and use the SDK
import io.hinkal.mobile.Mobile
// 1. Create the client and connect - derives the shielded identity.
val client = Mobile.newClient()
val address = client.connect(WalletHost(yourWallet))
val hinkal = client.hinkal()
// 2. Deposit (public → private)
val wei = Mobile.amountToWei(chainId, tokenAddress, "1.0")
val deposit = hinkal.deposit(chainId, "[\"$tokenAddress\"]", "[\"$wei\"]", true, false)
// 3. Transfer (private → private)
val transferWei = Mobile.amountToWei(chainId, tokenAddress, "0.5")
val transfer = hinkal.transfer(chainId, "[\"$tokenAddress\"]", "[\"$transferWei\"]",
recipientPrivateAddress, tokenAddress, "")
// 4. Withdraw (private → public)
val withdrawWei = Mobile.amountToWei(chainId, tokenAddress, "0.25")
val withdraw = hinkal.withdraw(chainId, "[\"$tokenAddress\"]", "[\"$withdrawWei\"]",
recipientPublicAddress, false, tokenAddress, "")Jetpack Compose Example
class WalletViewModel : ViewModel() {
private val _isConnected = MutableStateFlow(false)
val isConnected: StateFlow<Boolean> = _isConnected
private val _address = MutableStateFlow<String?>(null)
val address: StateFlow<String?> = _address
private var client: Client? = null
private var hinkal: Hinkal? = null
fun connect(wallet: YourWalletImplementation) = viewModelScope.launch {
client = Mobile.newClient()
_address.value = client?.connect(WalletHost(wallet))
hinkal = client?.hinkal()
_isConnected.value = _address.value != null
}
fun deposit(chainId: Long, tokenAddress: String) = viewModelScope.launch {
val wei = Mobile.amountToWei(chainId, tokenAddress, "1.0")
hinkal?.deposit(chainId, "[\"$tokenAddress\"]", "[\"$wei\"]", true, false)
}
fun disconnect() {
client?.disconnect()
_isConnected.value = false
_address.value = null
}
}
@Composable
fun WalletScreen(viewModel: WalletViewModel) {
val isConnected by viewModel.isConnected.collectAsState()
val address by viewModel.address.collectAsState()
if (isConnected) {
Text(address ?: "")
Button(onClick = { viewModel.deposit(chainId, tokenAddress) }) { Text("Deposit 1 Token") }
Button(onClick = { viewModel.disconnect() }) { Text("Disconnect") }
} else {
Button(onClick = { viewModel.connect(yourWallet) }) { Text("Connect Wallet") }
}
}