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

# useBatchPreparePermits

Mutation hook that builds unsigned EIP-712 typed data for decryption permits covering any number of contracts, one permit per 10.

[`usePreparePermit`](https://docs.zama.org/protocol/sdk/api-references/react/usepreparepermit.md) for any number of contracts. A permit holds at most 10, so `data` is an array with one `PreparedPermit` per chunk of 10 (a single element for 10 or fewer). Hand each `eip712` to the external signer for `eth_signTypedData_v4`, then pass the signed pairs to [`useBatchRegisterPermits`](https://docs.zama.org/protocol/sdk/api-references/react/usebatchregisterpermits.md).

## Import

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

## Usage

```tsx
import { useBatchPreparePermits } from "@zama-fhe/react-sdk";

function PrepareCustodyPermits({
  custodyAddress,
  tokenAddresses,
}: {
  custodyAddress: `0x${string}`;
  tokenAddresses: `0x${string}`[];
}) {
  const { mutateAsync: batchPreparePermits, isPending } = useBatchPreparePermits();

  const handlePrepare = async () => {
    const prepared = await batchPreparePermits({
      signer: custodyAddress,
      contracts: tokenAddresses,
    });
    // Hand each prepared[i].eip712 to the custody API for eth_signTypedData_v4,
    // then pass the { prepared, signature } pairs to useBatchRegisterPermits.
    return prepared;
  };

  return (
    <button onClick={handlePrepare} disabled={isPending}>
      {isPending ? "Preparing..." : "Prepare offline permits"}
    </button>
  );
}
```

## Parameters

`useBatchPreparePermits` takes no configuration parameters.

## Mutation variables

### request

`PreparePermitRequest` — the same fields as [`usePreparePermit`](https://docs.zama.org/protocol/sdk/api-references/react/usepreparepermit.md#request), without the 10-address limit on `contracts`.

## Return Type

Returns a standard TanStack Query `UseMutationResult<PreparedPermit[], Error, PreparePermitRequest>`. `data` is an array of `PreparedPermit` — every field is JSON-safe, so it crosses a process boundary as-is.

**Throws:**

* `ConfigurationError` - `request.contracts` is empty, `request.delegator` equals `request.signer`, or `request.durationDays` exceeds the V1 permit maximum of 365 days
* `TransportKeyPairChangedError` - a concurrent `permits.revokeTransportKeyPair()` rotated the transport key pair while this call was generating one

## Related

* [`useBatchRegisterPermits`](https://docs.zama.org/protocol/sdk/api-references/react/usebatchregisterpermits.md) -- verify and persist the signatures returned for the prepared permits
* [`usePreparePermit`](https://docs.zama.org/protocol/sdk/api-references/react/usepreparepermit.md) -- the single-permit form
* [Offline signing guide](https://docs.zama.org/protocol/sdk/guides/offline.md#offline-permits) -- the full offline permit workflow
* [Offline reference](https://docs.zama.org/protocol/sdk/api-references/sdk/offline.md#batchpreparepermits) -- `sdk.offline.batchPreparePermits`'s full signature and typed errors


---

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