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

# useUnderlyingAllowance

Read the ERC-20 allowance of the underlying public token for the wrapper contract.

Read the ERC-20 allowance of the underlying public token for the wrapper contract. Use this to check whether shielding requires an approval transaction.

## Import

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

## Usage

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

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

function AllowanceDisplay({
  wrapperAddress,
  owner,
}: {
  wrapperAddress: `0x${string}`;
  owner: `0x${string}` | undefined;
}) {
  const { data: allowance, isLoading } = useUnderlyingAllowance({ address: wrapperAddress, owner });

  if (isLoading) return <span>Loading allowance...</span>;
  return <span>Allowance: {allowance?.toString() ?? "0"}</span>;
}
```

{% endtab %}
{% endtabs %}

## Parameters

### address

`Address`

Address of the confidential wrapper contract. The hook reads the underlying ERC-20 allowance granted by `owner` to this wrapper.

```ts
const { data: allowance } = useUnderlyingAllowance({ address: "0xWrapper", owner: "0xOwner" });
```

***

### owner

`Address | undefined`

Address whose allowance to read. The query is disabled while `undefined`.

```ts
const { data: allowance } = useUnderlyingAllowance({ address: "0xWrapper", owner: "0xOwner" });
```

## Return Type

`data` is `bigint` — the current ERC-20 allowance in the token's base units.

## Suspense

Use `useUnderlyingAllowanceSuspense` inside a `<Suspense>` boundary. The hook throws a promise while loading, so `data` is always defined.

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

function Allowance({
  wrapperAddress,
  owner,
}: {
  wrapperAddress: `0x${string}`;
  owner: `0x${string}`;
}) {
  const { data: allowance } = useUnderlyingAllowanceSuspense({ address: wrapperAddress, owner });

  // data is always defined — no loading state needed
  return <span>Allowance: {allowance.toString()}</span>;
}

function App() {
  return (
    <Suspense fallback={<span>Loading...</span>}>
      <Allowance wrapperAddress="0xWrapper" owner="0xOwner" />
    </Suspense>
  );
}
```

## Related

* [`useShield`](/protocol/sdk/api-references/react/useshield.md) — shield tokens (handles approval automatically)
* [`useApproveUnderlying`](/protocol/sdk/api-references/react/useapproveunderlying.md) — the write counterpart; approve the wrapper to spend the underlying ERC-20
* [`zamaQueryKeys.underlyingAllowance`](/protocol/sdk/api-references/react/query-keys.md) — cache keys for manual invalidation


---

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