> For the complete documentation index, see [llms.txt](https://hinkal-team.gitbook.io/hinkal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hinkal-team.gitbook.io/hinkal/hinkal-mobile-sdk/android/guides/deposits.md).

# 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

```kotlin
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:

```kotlin
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`:

```kotlin
val wei = Mobile.amountToWei(chainId, tokenAddress, "1.5")   // human → wei
val human = Mobile.amountFromWei(chainId, tokenAddress, wei) // wei → human
```

### Error Handling

```kotlin
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.

```kotlin
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

```kotlin
hinkal.getTotalBalance(chainId, signature, address, true, false)
```
