This guide will help you set up the funding card functionality using OnchainKit's FundCard component.
Create a .env.local file in your project root with the following variables:
# OnchainKit Configuration (Client-side safe)
# Get these from https://portal.cdp.coinbase.com/
NEXT_PUBLIC_CDP_PROJECT_ID=your_project_id_here
NEXT_PUBLIC_ONCHAINKIT_API_KEY=your_onchainkit_api_key_here
NEXT_PUBLIC_ONCHAINKIT_PROJECT_NAME=BasedBills
# Optional: WalletConnect Project ID for wallet connections
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id_here- Go to Coinbase Developer Platform
- Create a new project or use an existing one
- In the project dashboard, find your Project ID
- Go to "OnchainKit" section and generate a new API key
If you want to use WalletConnect for wallet connections:
- Go to WalletConnect Cloud
- Create a new project
- Copy the Project ID
- Start the development server:
npm run dev - Navigate to
/fundingpage - Connect your wallet using the wallet connection in the top right corner
- Use the FundCard to purchase USDC
- Never commit
.env.localto version control - All environment variables are client-side safe
- OnchainKit handles all security internally
-
FundCard not showing
- Check that
NEXT_PUBLIC_CDP_PROJECT_IDis set correctly - Verify you're using a supported network (Base, Ethereum, etc.)
- Check that
-
Wallet connection issues
- Check that
NEXT_PUBLIC_WALLETCONNECT_PROJECT_IDis set if using WalletConnect - Make sure your wallet supports the Base network
- Check that
-
Environment variable not loading
- Restart the development server after adding environment variables
- Check that variables are prefixed correctly (
NEXT_PUBLIC_)
FundCardComponent- Main funding card using OnchainKit FundCardFundingPage- Test page for the funding functionality
The FundCard component provides:
- Amount input with fiat/crypto switching
- Payment method selection (Coinbase, Apple Pay, Debit Card)
- Preset amount buttons ($10, $25, $50)
- Real-time exchange rate updates
- Automatic wallet connection integration