A Next.js application that enables seamless conversion between stablecoins and fiat currencies using BlindPay's API and Dynamic wallet integration.
- Dynamic Wallet Integration: Connect wallets using Dynamic Labs
- BlindPay API Integration: Real-time conversion rates and execution
- KYC Verification Flow: Complete KYC verification to use BlindPay services
- User Metadata Storage: Receiver IDs stored in Dynamic user metadata
- Multi-Currency Support: Support for various stablecoins and fiat currencies
- Real-time Quotes: Get live conversion rates before executing trades
-
Install dependencies:
bun install
-
Set up environment variables: Create a
.env.local
file with the following variables:# BlindPay API Configuration (Required) BLINDPAY_API_URL=https://api.blindpay.com/v1 BLINDPAY_INSTANCE_ID=your_instance_id_here BLINDPAY_API_KEY=your_api_key_here # Dynamic Wallet Configuration (Required) NEXT_PUBLIC_DYNAMIC_ENVIRONMENT_ID=your_dynamic_environment_id_here # Contract Addresses (Optional - defaults provided) NEXT_PUBLIC_USDB_CONTRACT_ADDRESS=0x4D423D2cfB373862B8E12843B6175752dc75f795 # BlindPay Defaults (Optional - will use sensible defaults) BLINDPAY_DEFAULT_NETWORK=base_sepolia BLINDPAY_CURRENCY_TYPE=sender BLINDPAY_COVER_FEES=true BLINDPAY_PAYMENT_METHOD=ach BLINDPAY_STABLECOIN_TOKEN=USDC BLINDPAY_FIAT_CURRENCY=USD
To get your BlindPay credentials:
- Create an account on BlindPay
- Create a development instance
- Create your API key
- Note your instance ID and bank account ID
-
Run the development server:
bun run dev
-
Open your browser: Navigate to http://localhost:3000
- Wallet Connection: Users connect their wallet using Dynamic Labs
- KYC Verification: Users complete a KYC form with personal information
- Receiver Creation: BlindPay creates a receiver with the provided KYC data
- Metadata Storage: The receiver ID and banking ID are stored in Dynamic user metadata using the
useUserUpdateRequest
hook - Service Access: Users can now access BlindPay services using their stored receiver ID
- Data Persistence: All KYC data persists across sessions and devices via Dynamic's user metadata system
The KYC flow includes:
- Personal information (name, email, date of birth)
- Contact details (phone number)
- Address information (street, city, state_province_region, postal code)
- Document verification (proof of address, ID documents)
- KYC data is sent directly to BlindPay's secure API
- Receiver IDs are stored in Dynamic's encrypted user metadata
- No sensitive KYC data is stored locally
- Environment variables for development defaults
- Connect Wallet: Connect your wallet using Dynamic Labs
- Complete KYC: Complete KYC verification if not already done
- Enter Amount: Specify the USD amount to convert
- Create Quote: Get a quote for the conversion rate
- Get Banking Details: Receive BlindPay banking details and memo code
- ACH Transfer: Send ACH transfer to provided banking details with memo code
- Receive Tokens: USDC is automatically sent to your wallet after payment confirmation
- Connect Wallet: Connect your wallet using Dynamic Labs
- Complete KYC: Complete KYC verification if not already done
- Enter Amount: Specify the stablecoin amount to convert
- Create Quote: Get a quote for the conversion
- Approve Tokens: Approve BlindPay contract to spend your tokens
- Execute Payout: BlindPay processes the payout to your bank account
- KYCFlow: Handles KYC verification and receiver creation
- ConversionCard: UI for currency conversion inputs
- WalletInfo: Displays wallet balances and connection status
- TransactionHistory: Shows conversion history
/api/receivers
: Manages BlindPay receiver creation and TOS acceptance/api/payin
: Handles fiat-to-stablecoin conversions/api/convert
: Manages stablecoin-to-fiat conversions/api/banking-details
: Provides banking information for payins
- Dynamic Labs: Wallet connection and user metadata management
- BlindPay API: Conversion quotes, execution, and banking details
- Wagmi/Viem: Blockchain interactions and token approvals
- Update
config.currencies
insrc/lib/config.ts
- Add token mapping in
config.tokenMapping
- Update conversion logic in API routes
- Modify the
KYCFlow
component insrc/components/KYCFlow.tsx
- Update the receivers API route for additional KYC fields
- Add validation and error handling as needed
All configuration is done through environment variables to ensure:
- No hardcoded values in production
- Easy configuration management
- Secure credential handling
- KYC Required: Users must complete KYC verification before using BlindPay services
- Receiver ID Storage: Receiver IDs are automatically stored in Dynamic user metadata
- No Local Storage: Sensitive KYC data is not stored locally
- Development Mode: Uses placeholder KYC data for development (configure via env vars)