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

# useCrossChainDeposit

> Fund a Chipi wallet from Base or another EVM chain through Circle CCTP V2: quote both speeds, burn through the user EVM wallet, wait for the Starknet mint.

## Usage

```typescript theme={null}
const {
  quote,
  deposit,
  depositAsync,
  data,
  isLoading,
  isError,
  error,
  isSuccess,
  reset
} = useCrossChainDeposit();
```

### `quote(input)`

Both speeds for an amount, before anything is signed. Returns `Promise<Record<CctpFinality, CctpQuote>>`.

* `chain` (`CctpEvmChain`): the source chain, from `CCTP_EVM_CHAINS`.
* `amount` (string | number): human USDC, e.g. `"25"`.

Each `CctpQuote` has `feeBps`, `fee` and `feeUsdc` (Circle's fee, taken from the amount), `receives` and `receivesUsdc`, and `eta` (`{ minSeconds, maxSeconds }`, the attestation time; `formatCctpEta(eta)` turns it into copy).

### `depositAsync(input)`

* `provider` (`Eip1193Provider`): the user's EVM wallet, e.g. `(await discoverEvmWallets())[0].provider`.
* `chain` (`CctpEvmChain`): the source chain.
* `amount` (string | number): human USDC.
* `walletAddress` (string): the Chipi wallet that receives the USDC. It is the only possible recipient and is checked before signing.
* `finality` (`"standard"` | `"fast"`, optional): `standard` (default) is free and waits for the source chain's finality (15–20 minutes from an L2); `fast` costs Circle's fee and takes about a minute.
* `getBearerToken` (`() => Promise<string | null | undefined>`): called at every step, since tokens expire during the wait.
* `onStatus` (optional): `({ step, eta, burnTxHash?, mintTxHash? }) => void`. Steps: `quoting`, `switching-chain`, `approving`, `burning`, `registering`, `attesting`, `minting`, `recording`, `done`.
* `account` (optional): the EVM account to burn from; defaults to the wallet's first account.
* `pollIntervalMs` (optional, default 15000) and `timeoutMs` (optional, default 45 minutes): how the hook follows the mint. On timeout it resolves with `mintTxHash: null`; the deposit still completes server-side.

Resolves with `{ burnTxHash, sourceDomain, mintTxHash, account, batched, quote, startedAt }`.

### Errors

A `CrossChainDepositError` means the burn already happened on the source chain and a later step failed. It carries `burnTxHash` and `sourceDomain`: register again with `registerCctpDeposit`, or follow the deposit with `useCctpDepositStatus`. Any other error happened before signing; nothing moved.

### Return Value

* `quote`: the quote function above
* `deposit`: fire-and-forget deposit
* `depositAsync`: Promise-based deposit
* `data`: the last result
* `isLoading`, `isError`, `error`, `isSuccess`, `reset`: mutation state

## Example Implementation

```typescript theme={null}
import { useState } from "react";
import { useCrossChainDeposit } from "@chipi-stack/nextjs";
import { CCTP_EVM_CHAINS, discoverEvmWallets, formatCctpEta } from "@chipi-stack/backend";

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

export function FundFromBase({ chipiWallet, getToken }: { chipiWallet: string; getToken: () => Promise<string | null> }) {
  const { depositAsync, isLoading, error } = useCrossChainDeposit();
  const [status, setStatus] = useState("");

  const fund = async () => {
    const [evmWallet] = await discoverEvmWallets();
    if (!evmWallet) return setStatus("Install an EVM wallet first");
    const result = await depositAsync({
      provider: evmWallet.provider,
      chain: BASE,
      amount: "25",
      walletAddress: chipiWallet,
      getBearerToken: getToken,
      onStatus: ({ step, eta }) => setStatus(`${step} · ${formatCctpEta(eta)}`),
    });
    setStatus(`Arrived on Starknet: ${result.mintTxHash}`);
  };

  return (
    <div>
      <button onClick={fund} disabled={isLoading}>Bring 25 USDC from Base</button>
      <p>{error ? error.message : status}</p>
    </div>
  );
}
```


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