Skip to main content
Privy provides a useDepositFunds hook in @privy-io/react-auth that opens a funding modal. Your app can use this hook to let authenticated users fund a destination wallet with fiat, crypto, or both. A crypto-only call opens the crypto deposit flow directly. A call that includes fiat shows a method picker first.

Prerequisites

For fiat, enable card and bank funding methods on the Account Funding page. See the deposit configuration guide. For crypto, enable swaps and app-pays gas sponsorship as described in crypto deposit setup. Crypto deposits require a Privy wallet. The hook builds the create-deposit-account request and signs it with the user’s signer.

Access the hook

Import and initialize useDepositFunds:

Start a deposit flow

Call depositFunds with a destination and at least one funding method.
The crypto-only call opens the crypto deposit modal. The user picks a source token and network. Privy then creates a deposit account and shows the address with an indicative quote.
destination.chain and destination.asset accept aliases or raw identifiers. Omit destination.wallet to use the user’s first embedded wallet on that chain.
Pass both fiat and crypto to show a method picker:

Parameters

depositFunds accepts an object with the following fields:
object
required
Wallet and asset that receive the funds.
object
Enables the crypto deposit flow. Required unless fiat is provided. Pass {source: {mode: 'all'}} to accept every supported source.
object
Enables fiat funding with the card and bank onramp flow. Required unless crypto is provided.
At least one of fiat or crypto must be provided.

Return value

depositFunds returns a Promise with one of the following results:

Error handling

depositFunds rejects on invalid configuration or incomplete flows. Common error cases include:
  • the call omits destination.chain or destination.asset
  • the call omits both fiat and crypto
  • the call sends an empty fiat.source.assets list
  • the user has no authenticated session
  • destination.wallet is not a Privy wallet on a crypto call
  • another funding flow is already in progress
  • the user cancels the flow
  • swaps or app-pays gas sponsorship are not enabled
  • no source tokens match crypto.source
  • provider session, quote, or deposit account requests fail
Your app should wrap calls in try/catch and show clear UI feedback.

Complete example

Card onramps

Fund wallets with fiat via card, Apple Pay, or Google Pay.

Crypto deposits

Persistent deposit addresses, setup, and headless React or React Native.