Skip to content

Prompting users to fund wallets

TIP

Privy's funding flows require Privy UIs library to be integrated in your app. Prior to using Privy's funding interfaces, set up Privy UIs in your app with this guide.

Once you've enabled a set of funding methods for your app, to invoke the funding flow, use the useFundWallet hook from the Privy as follows:

tsx
import { useFundWallet } from "@privy-io/expo";
...
const {fundWallet} = useFundWallet();
await fundWallet({address: 'your-wallet-address-here'});

Once invoked, the fundWallet method will open a modal that contains a list of funding options the user can take.

You can pass additional configurations to the funding flow in the second, optional parameter to fundWallet.

WARNING

Purchases with third-party providers are not always instantaneous, and there may be some time before the user completes their purchase and the funds are available in their wallet.

Setting a funding amount in code

Optionally, you can pass in a chain, funding amount, and funding asset to fundWallet to override your Dashboard configuration.

To do so, as the second, optional parameter to fundWallet, pass an object with the following fields:

ParameterTypeDescription
addressstringThe destination address to fund.
chainChainOptional. A viem/chains object for the network on which users should fund their accounts. Defaults to the network you configured in the Privy Dashboard.
asset'native-currency' | 'USDC' | {tokenAddress: string}Optional. The asset you'd like the user to fund their accounts with. Set 'native-currency' to fund with the chain's native currency (e.g. ETH), 'USDC' to fund with USDC, or pass the token address to tokenAddress. Defaults to 'native-currency'.
amountstringRequired if asset is set, optional otherwise. The amount of the asset to fund as a decimal string. Defaults to the amount you configured in the Privy Dashboard.
tsx
import {useFundWallet} from '@privy-io/expo';
// Replace this with your desired network
import {base} from 'viem/chains'
...
// `fundWallet` from the useFundWallet() hook
fundWallet({
  address: '0x2F3eb40872143b77D54a6f6e7Cc120464C764c09',
  asset: "USDC",
  chain: base,
  amount: 1
})