With funding methods enabled for your app, MoonKey will prompt users to fund their wallets at two points in their experience:Documentation Index
Fetch the complete documentation index at: https://docs.streambird.io/llms.txt
Use this file to discover all available pages before exploring further.
- Manually - When you call MoonKey’s
fundWalletmethod - Automatically - When the user attempts to send a transaction but has insufficient funds
Manually invoking funding
Once you’ve enabled funding methods for your app in the Dashboard, use theuseFundWallet hook to invoke the funding flow:
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.
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 tofundWallet:
Basic parameters
The wallet address to fund.
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.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.The asset to fund with:
'native-currency'- SOL (Solana’s native currency)'USDC'- USDC stablecoin
'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 theonUserExited callback with the useFundWallet hook:
Callback parameters
TheonUserExited callback receives an object with:
The wallet address that was funded.
The Solana cluster where funding occurred.
The funding method used (e.g.,
'card').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 theuiConfig option:
UI configuration options
Custom title for the “Receive funds” screen.
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:onUserExited callback, remember that the balance is in lamports:
Best practices
Set appropriate amounts for Solana
Set appropriate amounts for Solana
- 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
Communicate funding status
Communicate funding status
- Explain that purchases are not instant
- Show expected delivery times (usually faster than Ethereum)
- Provide transaction status updates
- Handle edge cases gracefully
Use appropriate clusters
Use appropriate clusters
- Always use
'solana:mainnet'for production - Test your integration thoroughly on mainnet with small amounts
- Devnet is not supported for card funding
Consider USDC for price stability
Consider USDC for price stability
- 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
Use callbacks effectively
Use callbacks effectively
- Track funding completion with
onUserExited - Navigate users appropriately based on balance
- Log funding events for analytics
- Handle insufficient balance scenarios
Handle rent exemption
Handle rent exemption
- 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
Balance appears as 0 after funding
Balance appears as 0 after funding
Possible causes:
- Purchase not yet complete
- MoonPay processing payment
- Network congestion
- Wait a few minutes for processing
- Check MoonPay transaction status
- Refresh wallet balance after delay
Funding modal doesn't appear
Funding modal doesn't appear
Possible causes:
- Funding not enabled in Dashboard
- Incorrect cluster configuration
- Browser blocking popup
- Verify Dashboard configuration
- Check console for errors
- Ensure popups are allowed
Insufficient funds for transactions
Insufficient funds for transactions
Possible causes:
- Funded amount too small
- Account rent not covered
- Multiple transactions depleting balance
- 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