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

# useConfidentialTransferFromAndCall

Operator-initiated confidential transfer that also invokes the recipient's receiver hook in one transaction.

Operator-initiated `confidentialTransferFromAndCall` — an ERC-7984 confidential transfer on behalf of another address that also invokes the recipient's receiver hook in a single transaction. The caller must be an approved operator for `from` (grant approval via [`useConfidentialSetOperator`](/protocol/sdk/api-references/react/useconfidentialsetoperator.md)). The caller crafts the opaque `data` payload; the SDK does not encode, validate, or interpret it. Invalidates the [`useConfidentialBalance`](/protocol/sdk/api-references/react/useconfidentialbalance.md) cache on success.

## Import

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

## Usage

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

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

function OperatorTransferAndCall({ tokenAddress }: { tokenAddress: `0x${string}` }) {
  const { mutateAsync: transferFromAndCall, isPending } =
    useConfidentialTransferFromAndCall(tokenAddress);

  async function handleTransfer() {
    const { txHash } = await transferFromAndCall({
      from: "0xOwner",
      to: "0xReceiverContract",
      amount: 500n,
      data: "0xabcd",
    });
    console.log("Transfer confirmed:", txHash);
  }

  return (
    <button onClick={handleTransfer} disabled={isPending}>
      {isPending ? "Transferring..." : "Transfer"}
    </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

### address

`Address`

Contract address of the confidential token. Passed positionally as the first argument.

```ts
const { mutateAsync: transferFromAndCall } = useConfidentialTransferFromAndCall("0xToken");
```

***

## Mutation variables

```ts
import { type ConfidentialTransferFromAndCallParams } from "@zama-fhe/sdk/query";
```

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

### from

`Address`

Owner address whose tokens are being transferred. The connected wallet must have operator approval from this address.

### to

`Address`

Recipient address.

### amount

`bigint`

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

### data

`Hex`

Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. The caller is responsible for encoding this payload.

### callbacks

`TransferCallbacks | undefined`

Optional progress callbacks for the multi-step transfer flow: `onEncryptComplete` (fires after FHE encryption of the amount completes) and `onTransferSubmitted` (fires after the transfer transaction is submitted).

```ts
await transferFromAndCall({
  from: "0xOwner",
  to: "0xReceiverContract",
  amount: 500n,
  data: "0xabcd",
});
```

**Throws:**

* `SigningRejectedError` -- if the user rejects the wallet prompt
* `EncryptionFailedError` -- if FHE encryption of the transfer amount fails
* `TransactionRevertedError` -- if the on-chain transaction reverts

## 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 without a receiver hook
* [useConfidentialTransfer](/protocol/sdk/api-references/react/useconfidentialtransfer.md) -- direct transfer (no operator)
* [useConfidentialSetOperator](/protocol/sdk/api-references/react/useconfidentialsetoperator.md) -- grant operator approval
* [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/useconfidentialtransferfromandcall.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.
