> 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/useclaim.md). Agents can also search and read this documentation through its [MCP server](https://docs.zama.org/protocol/~gitbook/mcp).

# useClaim

Mutation hook that claims a finalized vault batch's output for an account.

Mutation hook that claims a finalized batch with the SDK's signer: shares for a deposit batch, the asset for a redeem batch. Wraps [`VaultClient.claim`](https://docs.zama.org/protocol/sdk/api-references/sdk/vaultclient.md#claim).

Any account may send the claim. The output goes to `account`.

## Import

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

## Usage

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

```tsx
import { useBatch, useClaim } from "@zama-fhe/react-sdk/vaults";
import type { BatchRef } from "@zama-fhe/sdk/vaults";
import type { Address } from "viem";

function ClaimButton({ batchRef, account }: { batchRef: BatchRef; account: Address }) {
  const { data: batch } = useBatch(batchRef, { account });
  const claim = useClaim();

  if (!batch?.actions.includes("claim")) return null;

  return (
    <button disabled={claim.isPending} onClick={() => claim.mutate({ ...batchRef, account })}>
      {claim.isPending ? "Claiming..." : "Claim"}
    </button>
  );
}
```

{% endtab %}
{% endtabs %}

## Parameters

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

## Mutation variables

A [`BatchRef`](https://docs.zama.org/protocol/sdk/api-references/sdk/vaultclient.md#batchref) plus an optional `account`, passed to `mutate` / `mutateAsync`.

### chainId

`number`

The chain of the batch to claim.

### batcher

`Address`

The batcher of the batch to claim.

### batchId

`bigint`

The batch to claim.

### account

`Address | undefined`

The account to claim for. Defaults to the signer.

**Throws:**

* `ChainMismatchError`: the wallet is not on the batch's chain.
* `TransactionRevertedError`: the claim reverted, for example because the batch is not finalized yet.

## Return Type

The `data` property (after a successful mutation) is a `TransactionResult`: `{ txHash, receipt }`.

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

## Related

* [useBatch](https://docs.zama.org/protocol/sdk/api-references/react/usebatch.md): when `claim` is available
* [useQuit](https://docs.zama.org/protocol/sdk/api-references/react/usequit.md): take a deposit back instead


---

# 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/useclaim.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.
