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

# useTotalSupply

Read the total supply of a token.

Read the total supply of a token. The result goes stale after 30 seconds to balance freshness against RPC cost.

## Import

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

## Usage

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

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

function TotalSupply({ tokenAddress }: { tokenAddress: `0x${string}` }) {
  const { data: totalSupply, isLoading } = useTotalSupply(tokenAddress);

  if (isLoading) return <span>Loading total supply...</span>;
  return <span>Total supply: {totalSupply?.toString() ?? "0"}</span>;
}
```

{% endtab %}
{% endtabs %}

## Parameters

### tokenAddress

`Address`

Address of the token contract to read the total supply from.

```ts
const { data: totalSupply } = useTotalSupply("0xToken");
```

### options

`Omit<UseQueryOptions<bigint>, "queryKey" | "queryFn"> | undefined`

Standard React Query options, forwarded to `useQuery`. Passed as the second argument.

## Return Type

`data` is `bigint` — the token's total supply in its base units.

## Caching

The query uses a 30-second `staleTime`. Within that window the cached value is served without re-fetching; afterwards it re-fetches on the next access.

## Suspense

Use `useTotalSupplySuspense` inside a `<Suspense>` boundary to avoid manual loading state handling. The hook suspends rendering until the total supply is loaded, so `data` is always defined.

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

function TotalSupply({ tokenAddress }: { tokenAddress: `0x${string}` }) {
  const { data: totalSupply } = useTotalSupplySuspense(tokenAddress);

  // data is always defined — no loading state needed
  return <span>Total supply: {totalSupply.toString()}</span>;
}
```

## Related

* [useMetadata](/protocol/sdk/api-references/react/usemetadata.md) -- read token name, symbol, and decimals
* [useConfidentialBalance](/protocol/sdk/api-references/react/useconfidentialbalance.md) -- read the decrypted confidential balance


---

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