> 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/usepreparepermit.md).

# usePreparePermit

Mutation hook that builds the unsigned EIP-712 typed data for a decryption permit, without signing it.

Mutation hook that builds the unsigned EIP-712 typed data for a decryption permit, without signing it — for custody partners (HSM, policy engines, out-of-process signers) that cannot sign in-process. Hand `data.eip712` to the external signer for `eth_signTypedData_v4`, then pass the returned signature to [`useRegisterPermit`](/protocol/sdk/api-references/react/useregisterpermit.md).

Prefer [`useGrantPermit`](/protocol/sdk/api-references/react/usegrantpermit.md) unless signing must happen out-of-process: this is the offline, low-level counterpart — one permit per call, no widening or chunking against existing permits.

## Import

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

## Usage

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

function PrepareCustodyPermit({
  custodyAddress,
  tokenAddress,
}: {
  custodyAddress: `0x${string}`;
  tokenAddress: `0x${string}`;
}) {
  const { mutateAsync: preparePermit, isPending } = usePreparePermit();

  const handlePrepare = async () => {
    const prepared = await preparePermit({ signer: custodyAddress, contracts: [tokenAddress] });
    // Hand prepared.eip712 to the custody API for eth_signTypedData_v4,
    // then pass the returned signature to useRegisterPermit.
    return prepared;
  };

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

## Parameters

`usePreparePermit` takes no configuration parameters.

## Mutation variables

### request

`PreparePermitRequest`

| Field          | Type        | Default                                         | Meaning                                             |
| -------------- | ----------- | ----------------------------------------------- | --------------------------------------------------- |
| `signer`       | `Address`   | required                                        | address expected to sign the returned `eip712`      |
| `contracts`    | `Address[]` | required, max 10 (see `useBatchPreparePermits`) | contract addresses to authorize                     |
| `delegator`    | `Address`   | none — self permit; must differ from `signer`   | delegator address, for a delegated permit           |
| `durationDays` | `number`    | the SDK's configured `permitTTL`, max 365       | permit validity window in days, a V1 protocol limit |

Signer-optional: `request.signer` is an explicit address, not a connected wallet account — building the typed data needs no configured signer, only a reachable provider (it reads the chain's KMS signers context on-chain).

```tsx
const prepared = await preparePermit({
  signer: custodyAddress,
  contracts: [tokenAddress],
  // delegator: ownerAddress,   // omit for a self permit
  // durationDays: 30,          // defaults to the SDK's configured permitTTL
});
```

## Return Type

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

**Throws:**

* `ConfigurationError` - `request.contracts` is empty or exceeds 10 addresses, `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

* [`useRegisterPermit`](/protocol/sdk/api-references/react/useregisterpermit.md) -- verify and persist the signature returned for a prepared permit
* [`useBatchPreparePermits`](/protocol/sdk/api-references/react/usebatchpreparepermits.md) -- the same, for more than 10 contracts (one permit per 10)
* [`useGrantPermit`](/protocol/sdk/api-references/react/usegrantpermit.md) -- the atomic, wallet-connected counterpart
* [Offline signing guide](/protocol/sdk/guides/offline.md#offline-permits) -- the full offline permit workflow
* [Offline reference](/protocol/sdk/api-references/sdk/offline.md#preparepermit) -- `sdk.offline.preparePermit`'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/usepreparepermit.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.
