> For the complete documentation index, see [llms.txt](https://docs.zama.org/protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zama.org/protocol/sdk/api-references/react/usedeposit.md). Agents can also search and read this documentation through its [MCP server](https://docs.zama.org/protocol/~gitbook/mcp).

# useDeposit

Mutation hook that deposits into a confidential vault group and returns the batch each leg landed in.

Mutation hook that deposits into a vault group, or a vault on its own, with the SDK's signer. Wraps [`VaultClient.deposit`](https://docs.zama.org/protocol/sdk/api-references/sdk/vaultclient.md#deposit).

The mutation resolves once the deposit has joined a batch, not once it has settled. [`useBatch`](https://docs.zama.org/protocol/sdk/api-references/react/usebatch.md) reads each returned batch.

## Import

```ts
import { useDeposit } from "@zama-fhe/react-sdk/vaults";
```

## Usage

{% tabs %}
{% tab title="DepositButton.tsx" %}

```tsx
import { useDeposit } from "@zama-fhe/react-sdk/vaults";
import { STABLE } from "./vaults";

function DepositButton() {
  const deposit = useDeposit({ onSuccess: ({ batches }) => saveBatches(batches) });

  return (
    <button
      disabled={deposit.isPending}
      onClick={() => deposit.mutate({ group: STABLE, vaultId: "beta", amount: 1_000_000n })}
    >
      {deposit.isPending ? "Depositing..." : "Deposit"}
    </button>
  );
}
```

{% endtab %}
{% endtabs %}

`saveBatches` stands in for your own storage. See [Store the batches](https://docs.zama.org/protocol/sdk/vaults/deposits.md#4-store-the-batches).

## Parameters

```ts
import { type UseVaultMutationOptions } from "@zama-fhe/react-sdk/vaults";
```

## Mutation variables

```ts
import { type JoinVariables } from "@zama-fhe/sdk/vaults";
```

Passed to `mutate` / `mutateAsync` at call time.

### group

`VaultGroup | undefined`

The group to join, as returned by [`defineVaultGroup`](https://docs.zama.org/protocol/sdk/api-references/sdk/vaultclient.md#definevaultgroup). Pass `group` and `vaultId`, or `vault`.

### vault

`Vault | undefined`

A vault to join on its own instead of a group, as returned by [`defineVault`](https://docs.zama.org/protocol/sdk/api-references/sdk/vaultclient.md#definevault). It takes no `vaultId`.

### vaultId

`string | undefined`

The vault of `group` that gets the amount. Required with `group`. Omit it with `vault`.

The hook types `vaultId` as `string`, not as the ids of `group`. An id outside the group compiles, and the mutation throws `ConfigurationError`.

### amount

`bigint`

The amount, in the asset's base units. Encrypted before it leaves the SDK.

### skipBalanceCheck

`boolean | undefined`

Skips the balance check, which runs by default.

### onJoinSubmitted

`((txHash: Hex) => void) | undefined`

Called once the wallet has sent the join, before the SDK waits for the receipt. See [The send](https://docs.zama.org/protocol/sdk/vaults/building-a-ui.md#the-send).

**Throws:**

As [`VaultClient.deposit`](https://docs.zama.org/protocol/sdk/api-references/sdk/vaultclient.md#deposit). The ones a UI handles most:

* `VaultBatcherPausedError`: a batcher of the group is paused.
* `InsufficientConfidentialBalanceError`: the balance is below `amount`.
* `ChainMismatchError`: the wallet is not on the group's chain.
* `VaultJoinUnconfirmedError`: the join was mined, but the SDK could not read every batch from the receipt.

## Return Type

The `data` property (after a successful mutation) is a [`JoinOutcome`](https://docs.zama.org/protocol/sdk/api-references/sdk/vaultclient.md#joinoutcome): `batches`, the batch each leg landed in, and `txHashes`.

When the mutation settles, successful or not, the hook invalidates every vault read and every confidential balance.

## Related

* [useRedeem](https://docs.zama.org/protocol/sdk/api-references/react/useredeem.md): the redeem direction
* [useBatch](https://docs.zama.org/protocol/sdk/api-references/react/usebatch.md): follow each batch
* [Vault deposits and redemptions](https://docs.zama.org/protocol/sdk/vaults/deposits.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zama.org/protocol/sdk/api-references/react/usedeposit.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
