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

ParameterTypeDescription
chainIDLongTarget chain id.
tokenAddrsJSONStringJSON array of token addresses.
amountsWeiJSONStringJSON array of amounts in wei, matching tokenAddrsJSON.
preEstimateGasBooleanEstimate gas before submitting.
returnTxDataBooleanReturn 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 → human

Error 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)