> 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. 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 smallest unit.

## 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)
* [`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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
