Hinkal Mobile SDK
Deposits
A deposit moves tokens from the public wallet into the private balance (public → private). It is signed and broadcast through your host wallet.
Basic Deposit
val wei = Mobile.amountToWei(chainId, tokenAddress, "1.0")
val txHash = hinkal.deposit(
chainId,
"[\"$tokenAddress\"]", // tokenAddrsJSON
"[\"$wei\"]", // amountsWeiJSON
true, // preEstimateGas
false, // returnTxData
)Parameters
| Parameter | Type | Description |
|---|---|---|
chainID | Long | Target chain id. |
tokenAddrsJSON | String | JSON array of token addresses. |
amountsWeiJSON | String | JSON array of amounts in wei, matching tokenAddrsJSON. |
preEstimateGas | Boolean | Estimate gas before submitting. |
returnTxData | Boolean | Return unsigned tx data instead of broadcasting. |
Depositing multiple tokens
Because tokens and amounts are JSON arrays, one call deposits several tokens at once:
val usdcWei = Mobile.amountToWei(chainId, usdc, "100")
val wethWei = Mobile.amountToWei(chainId, weth, "0.5")
val txHash = hinkal.deposit(
chainId,
"[\"$usdc\", \"$weth\"]",
"[\"$usdcWei\", \"$wethWei\"]",
true,
false,
)Parsing amounts
Amounts cross the boundary in base units (wei). Convert with Mobile.amountToWei, and back with Mobile.amountFromWei:
val wei = Mobile.amountToWei(chainId, tokenAddress, "1.5") // human → wei
val human = Mobile.amountFromWei(chainId, tokenAddress, wei) // wei → humanError Handling
try {
val txHash = hinkal.deposit(chainId, "[\"$tokenAddress\"]", "[\"$wei\"]", true, false)
} catch (e: Exception) {
Log.e("Hinkal", "Deposit failed: ${e.message}")
}Best Practices
1. Validate the amount before submitting
Mobile.amountToWei throws if the token has fewer decimals than provided - convert first.
val wei = Mobile.amountToWei(chainId, tokenAddress, amountText)2. Ensure the wallet is funded
A deposit is broadcast by your host wallet, so it needs the token balance plus native gas (and, for ERC-20, an allowance to the Hinkal contract).
3. Refresh the balance afterward
hinkal.getTotalBalance(chainId, signature, address, true, false)