Skip to main content
With funding methods enabled for your app, MoonKey will prompt users to fund their wallets at two points in their experience:
  1. Manually - When you call MoonKey’s fundWallet method
  2. Automatically - When the user attempts to send a transaction but has insufficient funds
You can configure the cluster, asset, and amount that users should fund their wallets with directly in code.

Manually invoking funding

Once you’ve enabled funding methods for your app in the Dashboard, use the useFundWallet hook to invoke the funding flow:
Once invoked, the fundWallet method will open a modal with funding options for the user. If only one funding method is enabled, MoonKey will navigate directly to that flow.
Purchases with third-party providers (like MoonPay) are not always instantaneous. There may be some time before the user completes their purchase and the funds are available in their wallet.

Automatically invoking funding

When a user attempts to send a transaction but doesn’t have sufficient funds, MoonKey will automatically show them an β€œAdd funds” button in the transaction modal that enables them to invoke funding flows. This helps users complete their intended actions without leaving your application.

Setting funding parameters in code

You can override your Dashboard configuration by passing parameters to fundWallet:

Basic parameters

string
required
The wallet address to fund.
string
The Solana cluster to fund on. Use 'solana:mainnet' for mainnet, 'solana:devnet' for devnet.If not specified, defaults to the cluster configured in your Dashboard.
string
The amount of the asset to fund as a decimal string (e.g., '0.1').If not specified, defaults to the amount configured in your Dashboard.
'native-currency' | 'USDC'
The asset to fund with:
  • 'native-currency' - SOL (Solana’s native currency)
  • 'USDC' - USDC stablecoin
Defaults to 'native-currency'.
Only use 'solana:mainnet' for production. Testnets are not supported for card funding.

Examples

Fund with SOL

Fund with the native currency (SOL):

Fund with USDC

Fund with USDC stablecoin:

Fund with custom amounts

Allow users to choose their funding amount:

Predefined funding options

Offer preset funding amounts:

Callbacks

To understand when users have gone through a funding flow, use the onUserExited callback with the useFundWallet hook:

Callback parameters

The onUserExited callback receives an object with:
string
The wallet address that was funded.
string
The Solana cluster where funding occurred.
string
The funding method used (e.g., 'card').
bigint
The current balance of the wallet being funded (in lamports).

Onboarding flow example

Prompt new users to fund their wallet as part of onboarding:

Customizing the UI

Customize the β€œReceive funds” screen with the uiConfig option:

UI configuration options

string
Custom title for the β€œReceive funds” screen.
string
Custom subtitle for the β€œReceive funds” screen.

Complete example

Here’s a complete example with amount and asset selection:

Understanding Solana balances

Solana balances are measured in lamports, where 1 SOL = 1,000,000,000 lamports:
When checking balances in the onUserExited callback, remember that the balance is in lamports:

Best practices

  • Solana has very low transaction fees (typically < $0.01)
  • Smaller amounts work well (0.1 - 1 SOL is often sufficient)
  • Consider typical transaction costs in your app
  • Don’t require users to fund more than necessary
  • Explain that purchases are not instant
  • Show expected delivery times (usually faster than Ethereum)
  • Provide transaction status updates
  • Handle edge cases gracefully
  • Always use 'solana:mainnet' for production
  • Test your integration thoroughly on mainnet with small amounts
  • Devnet is not supported for card funding
  • USDC provides price stability for users
  • Useful for applications with fixed pricing
  • Still allows for Solana transactions
  • May be preferred by users concerned about volatility
  • Track funding completion with onUserExited
  • Navigate users appropriately based on balance
  • Log funding events for analytics
  • Handle insufficient balance scenarios
  • Solana accounts require minimum balance for rent exemption
  • Ensure funded amounts are sufficient for account creation
  • Consider rent costs when setting minimum balances
  • Guide users if their balance is below rent exemption

Common issues

Possible causes:
  • Purchase not yet complete
  • MoonPay processing payment
  • Network congestion
Solutions:
  • Wait a few minutes for processing
  • Check MoonPay transaction status
  • Refresh wallet balance after delay
Possible causes:
  • Funding not enabled in Dashboard
  • Incorrect cluster configuration
  • Browser blocking popup
Solutions:
  • Verify Dashboard configuration
  • Check console for errors
  • Ensure popups are allowed
Possible causes:
  • Funded amount too small
  • Account rent not covered
  • Multiple transactions depleting balance
Solutions:
  • Suggest higher funding amounts
  • Explain Solana rent requirements
  • Provide balance warnings before transactions

Next steps

Ethereum Funding

Fund Ethereum wallets

Card Payments

Learn about card payment options

Configure Funding

Set up funding in the Dashboard

Send Transaction

Use funded wallets to send transactions