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

# Deposit and deliver to your app

> Combine wallet, card or exchange funding with delivery to your application's receiving address

Use SDK **5.0.2** to combine funding, an escrow deposit and delivery to your app in one
`SpiceDeposit`. This example delivers USDC to a Cloak receiving address on Elysium. Your app
creates that address and verifies the final transfer before crediting its private balance.

## Set up the providers and wallet

Pin `@spicenet-io/spiceflow-ui@5.0.2`. If you import core directly, pin
`@spicenet-io/spiceflow-core@0.10.3` too. Mount your existing Privy, wagmi and Query providers
as shown in [Quick Start](https://spiceflow-docs.spicenet.io/quickstart.md), then configure Spice Flow:

```tsx theme={null}
<SpiceFlowProvider
  provider="privy"
  network="mainnet"
  mode="7702"
  nativeChainId={99901}
  swapper={{ enabled: true }}
  rpcOverrides={{ 99901: "https://rpc.elysium.kinetiq.xyz" }}
>
  {children}
</SpiceFlowProvider>
```

`swapper.enabled` makes Card and Exchange available alongside Wallet. Payment methods,
eligibility, minimums and funding-route fees still depend on the provider's live quote.
Set RPC overrides for any other chains your app exercises as needed.

Establish a [recoverable login](https://spiceflow-docs.spicenet.io/guides/wallet-recovery.md) before accepting funds. A guest must
link its login while the original account is accessible. Keep the same embedded wallet and
the same issued receiving address until that deposit and its delivery are resolved.

## Build the delivery inside the deposit

The SDK supplies `context.destinationAmount` in destination-token smallest units. It is the
deposit's net escrow amount, used here as the **total payout budget**.
`quoteSpicenetWithdrawalBatches` quotes payout fees within that budget and builds both the
Spicenet withdrawal and destination transfers. Pass the amount unchanged; do not subtract
payout fees yourself or replace it with an earlier card or exchange quote.

```tsx theme={null}
import { useCallback } from "react";
import type { Address } from "viem";
import {
  SpiceDeposit,
  quoteSpicenetWithdrawalBatches,
  useSpiceExecution,
  type PostDepositContext,
} from "@spicenet-io/spiceflow-ui";

const ELYSIUM_CHAIN_ID = 99901;
const ELYSIUM_USDC: Address = "0xb47c4C8F73F009CC0C0d3f92B388d13E293F0B65";

type Props = {
  isOpen: boolean;
  onClose: () => void;
  receiveAddress: Address;
  embeddedWalletAddress: Address;
  onDeliveryTransaction: (delivery: {
    txHash: string;
    recipient: Address;
    chainId: number;
    token: Address;
  }) => void;
};

export function DepositToCloak({
  isOpen,
  onClose,
  receiveAddress,
  embeddedWalletAddress,
  onDeliveryTransaction,
}: Props) {
  const { estimate } = useSpiceExecution();

  const deliveryBatches = useCallback(async (context: PostDepositContext) => {
    if (context.destinationAmount === undefined || context.destinationAmount <= 0n) {
      throw new Error("A positive destination amount is required");
    }

    return quoteSpicenetWithdrawalBatches({
      amount: context.destinationAmount,
      recipient: receiveAddress,
      token: ELYSIUM_USDC,
      chainId: ELYSIUM_CHAIN_ID,
      userAddress: embeddedWalletAddress,
      estimate,
    });
  }, [estimate, receiveAddress, embeddedWalletAddress]);

  return (
    <SpiceDeposit
      isOpen={isOpen}
      onClose={onClose}
      skipRecovery={false}
      destinationChainId={ELYSIUM_CHAIN_ID}
      destinationTokenAddress={ELYSIUM_USDC}
      depositActionLabel="Delivery to Cloak on Elysium"
      depositBatches={deliveryBatches}
      onDepositSuccess={(detail) => {
        if (detail.type === "deposit" && detail.txHash) {
          onDeliveryTransaction({
            txHash: detail.txHash,
            recipient: receiveAddress,
            chainId: ELYSIUM_CHAIN_ID,
            token: ELYSIUM_USDC,
          });
        }
      }}
    />
  );
}
```

Render the component only after your host has the authenticated embedded wallet and the
receiving address for this deposit. `onDeliveryTransaction` is a host callback that starts
receipt verification; it is not supplied by the SDK. `onDepositSuccess` is a notification
and does not await your application's verification or crediting work.

Remove the separate `SpiceWithdraw` step from this combined deposit flow. For a separate
withdrawal from an existing Spicenet balance, `SpiceWithdraw` still supports
[`recipient={receiveAddress}`](https://spiceflow-docs.spicenet.io/sdk/components#spicewithdraw).

## Verify delivery before crediting

For this combined flow, use `detail.txHash` to find the final Elysium receipt.
`detail.amount` is the escrow credit, **not** the net USDC delivered to Cloak. The modal can
show the actual delivered amount when it reads the receipt; the callback amount retains
its escrow-credit meaning.

Your host verifier must wait for Elysium finality and match the canonical USDC contract,
the issued receiving address and the transfer from the configured Elysium escrow. Credit
the amount from that receipt once, using the transaction hash and log index to identify
the transfer. See [Elysium mainnet](https://spiceflow-docs.spicenet.io/sdk/configuration.md#elysium-mainnet) for the token and escrow.
Keep the application status pending until verification and private-balance credit succeed.

Before launch, test that the final transfer credits the expected private balance in your
actual integration. SDK completion alone does not establish that application credit.

## Recover interrupted funding

Reopen the same `SpiceDeposit` with `skipRecovery={false}`, the same guest or linked account,
the same receiving address and the same `depositBatches` callback. Keep those values with
the host's original deposit record, including after a browser reload.

Confirm the existing funded balance to continue without paying again. If an action was
already submitted, inspect its [existing status](https://spiceflow-docs.spicenet.io/api-reference/endpoint/actions-get.md#recovering-the-original-operation)
before retrying. Preserve its identity and original transfers; an uncertain payment or
submission is not permission to send it again. A recovery attempt must not allocate a new
receiving address or create a replacement guest account.


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