> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chipipay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# useCrossChainWithdraw

> Withdraw USDC from a Chipi wallet to Base or another EVM chain through Circle CCTP V2, gaslessly: quote, burn on Starknet, Chipi delivers on the destination.

## Usage

```typescript theme={null}
const {
  quote,
  withdraw,
  withdrawAsync,
  data,
  isLoading,
  isError,
  error,
  isSuccess,
  reset
} = useCrossChainWithdraw();
```

### `quote(input)`

What the withdrawal costs this user, from Chipi: `{ feeBps, sponsored, userReceives }`. `sponsored` says whether Chipi pays Circle's fee back to the recipient on the destination chain.

* `chain` (`CctpEvmChain`), `amount` (string | number), `walletAddress` (string: the Chipi wallet), `getBearerToken`.

### `withdrawAsync(input)`

* The signer, as `useCallAnyContract`: `wallet` (`WalletData`), and either `usePasskey: true` with `externalUserId` (and optionally `credentialId`) or an `encryptKey`.
* `chain` (`CctpEvmChain`): the destination chain, from `CCTP_EVM_CHAINS`.
* `recipient` (string): the destination EVM address. Checked before signing: 40 hex digits, not the zero address, and a correct EIP-55 checksum when it carries mixed case.
* `amount` (string | number): human USDC.
* `getBearerToken` (`() => Promise<string | null | undefined>`): asked at every step.
* `onStatus` (optional): `({ step, eta, burnTxHash?, destTxHash? }) => void`. Steps: `quoting`, `burning`, `attesting`, `recording`, `finalizing`, `done`.

Withdrawals always use fast finality (a standard transfer out of Starknet waits hours for the L1 proof). The burn's `maxFee` is the quoted fee, so Circle attests fast; Circle only takes the real fee.

Resolves with `{ burnTxHash, destTxHash, recipient, quote }`.

### Errors

A `CrossChainWithdrawError` means the Starknet burn is done and the delivery did not finish. It carries `burnTxHash`: call `finalizeCrossChainWithdrawal` again (the relayer is idempotent). Any other error happened before signing.

## Example Implementation

```typescript theme={null}
import { useCrossChainWithdraw } from "@chipi-stack/nextjs";
import { CCTP_EVM_CHAINS } from "@chipi-stack/backend";
import type { WalletData } from "@chipi-stack/types";

const BASE = CCTP_EVM_CHAINS.find((c) => c.key === "base")!;

export function WithdrawToBase({ wallet, externalUserId, recipient, getToken }: {
  wallet: WalletData;
  externalUserId: string;
  recipient: string;
  getToken: () => Promise<string | null>;
}) {
  const { withdrawAsync, isLoading, error } = useCrossChainWithdraw();
  const withdraw = async () => {
    const result = await withdrawAsync({
      wallet,
      usePasskey: true,
      externalUserId,
      chain: BASE,
      recipient,
      amount: "7.81",
      getBearerToken: getToken,
    });
    console.log("delivered on Base:", result.destTxHash);
  };
  return <button onClick={withdraw} disabled={isLoading}>{error ? error.message : "Withdraw to Base"}</button>;
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.