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

# useConfidentialTransfer

Send confidential ERC-20 tokens privately.

Send confidential ERC-20 tokens privately. The amount is encrypted client-side before the transaction is submitted on-chain. Automatically invalidates the [`useConfidentialBalance`](/protocol/sdk/api-references/react/useconfidentialbalance.md) cache on success.

## Import

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

## Usage

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

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

function SendButton({ tokenAddress }: { tokenAddress: `0x${string}` }) {
  const { mutateAsync: transfer, isPending } = useConfidentialTransfer({ address: tokenAddress });

  async function handleSend() {
    const { txHash } = await transfer({ to: "0xRecipient", amount: 1000n });
    console.log("Transfer confirmed:", txHash);
  }

  return (
    <button onClick={handleSend} disabled={isPending}>
      {isPending ? "Sending..." : "Send"}
    </button>
  );
}
```

{% endtab %}

{% tab title="config.ts" %}

```ts
// config.ts
import { createConfig as createZamaConfig } from "@zama-fhe/react-sdk/wagmi";
import { web } from "@zama-fhe/sdk/web";
import { sepolia } from "@zama-fhe/sdk/chains";
import type { FheChain } from "@zama-fhe/sdk/chains";
import { config as wagmiConfig } from "./wagmi";

const mySepolia = {
  ...sepolia,
  relayerUrl: "https://your-app.com/api/relayer/11155111",
} as const satisfies FheChain;

export const zamaConfig = createZamaConfig({
  chains: [mySepolia],
  wagmiConfig,
  relayers: { [mySepolia.id]: web() },
});

// In your app layout:
// <ZamaProvider config={zamaConfig}>
//   <App />
// </ZamaProvider>
```

{% endtab %}
{% endtabs %}

## Parameters

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

### address

`Address`

Contract address of the confidential token.

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

```tsx
const { mutateAsync: transfer } = useConfidentialTransfer({ address: "0xToken" });
```

{% endtab %}
{% endtabs %}

### optimistic

`boolean | undefined`

Default: `false`. When `true`, optimistically subtracts the transfer amount from the cached confidential balance before the transaction confirms; rolls back on error.

```tsx
const { mutateAsync: transfer } = useConfidentialTransfer({ address: "0xToken", optimistic: true });
```

***

## Mutation variables

The function passed to `mutate` / `mutateAsync` accepts:

### to

`Address`

Recipient address.

### amount

`bigint`

Number of tokens to transfer (in the token's base units). Encrypted before submission.

### skipBalanceCheck

`boolean | undefined`

Skip confidential balance validation before submitting. Defaults to `false`. Useful for smart wallets that cannot produce EIP-712 signatures for balance decryption.

### onEncryptComplete

`(() => void) | undefined`

Fires when FHE encryption of the amount completes.

### onTransferSubmitted

`((txHash: Hex) => void) | undefined`

Fires when the transfer transaction is submitted on-chain.

```tsx
await transfer({
  to: "0xRecipient",
  amount: 1000n,
  onEncryptComplete: () => updateUI("Encrypted, submitting..."),
  onTransferSubmitted: (txHash) => updateUI(`Submitted: ${txHash}`),
});
```

**Throws:**

* `InsufficientConfidentialBalanceError` -- if the confidential balance is less than `amount` (exposes `requested`, `available`, `token`)
* `BalanceCheckUnavailableError` -- if balance validation is required but decryption is not possible (no stored permits). Grant a permit first with `useGrantPermit`, or use `skipBalanceCheck: true`

## Return Type

The `data` property (after a successful mutation) is `{ txHash: Hex, receipt: TransactionReceipt }`.

* **`txHash`** -- Transaction hash submitted to the network.
* **`receipt`** -- Confirmed transaction receipt from the chain.

## Related

* [useConfidentialTransferFrom](/protocol/sdk/api-references/react/useconfidentialtransferfrom.md) -- operator transfer variant
* [Transfer Privately guide](/protocol/sdk/guides/transfer-privately.md)
* [useConfidentialBalance](/protocol/sdk/api-references/react/useconfidentialbalance.md) -- auto-invalidated on success


---

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