A web application that enables users to purchase Colombian Pesos Digital (cCOP) using credit cards through Coinbase CDP Onramp, with automatic Celo to cCOP conversion via Uniswap V3.
A web application that enables users to purchase Colombian Pesos Digital (cCOP) using credit cards through Coinbase CDP Onramp, with automatic Celo to cCOP conversion via Uniswap V3.
📖 Description (Detailed)
🎯 Project Overview
This project creates a seamless bridge between traditional Colombian Pesos (COP) and the Celo blockchain's stablecoin cCOP. Users can input COP amounts (100K, 250K, 500K, 1M) and receive cCOP directly in their wallet without needing to understand blockchain complexity.
🔄 Core Flow
- User Input: User enters COP amount or selects predefined amounts
- Fiat Onramp: Credit card payment processed through Coinbase CDP Onramp
- Asset Acquisition: User receives CELO tokens on Celo blockchain
- Automatic Swap: Backend automatically swaps CELO → USDT → cCOP via Uniswap V3
- Final Delivery: User receives cCOP in their specified wallet address
💡 Key Innovation
The project eliminates the traditional multi-step process where users would need to:
- Buy crypto with fiat
- Transfer to a DEX
- Manually swap tokens
- Handle gas fees and slippage
Instead, users get a one-click experience from COP to cCOP, making DeFi accessible to non-technical users in Colombia.
🌍 Real-World Impact
- Financial Inclusion: Enables Colombians to access DeFi without crypto knowledge
- Remittances: Facilitates cross-border payments with minimal fees
- Stablecoin Adoption: Promotes cCOP usage in the Colombian market
- Regulatory Compliance: Uses Coinbase's compliant onramp infrastructure
🔧 How It's Made (Technical Deep Dive)
🏗️ Architecture Overview
The project uses a microservices architecture with clear separation between frontend, backend, and blockchain interactions:
Frontend (React) ↔ Backend (Node.js) ↔ CDP APIs ↔ Celo Blockchain
��️ Frontend Layer
- Framework: React 18 with Vite for fast development and HMR
- State Management: React hooks for local state management
- Styling: Custom CSS with modern gradients and responsive design
- Components: Modular architecture with reusable components:
QuoteDisplay
: Shows real-time conversion rates and fees
FlowInfo
: Visual representation of the COP → CELO → cCOP flow
APITester
: Development tool for testing CDP integration
⚙️ Backend Layer
- Runtime: Node.js with Express.js framework
- Authentication: JWT generation using Coinbase's private key infrastructure
- API Proxy: Acts as middleware between frontend and CDP APIs
- Security: Implements proper CORS, input validation, and error handling
🔐 Authentication System
The most complex part of the project is the JWT authentication flow:
// JWT Generation Process
const payload = {
iss: CDP_API_KEY, // Issuer (API Key)
sub: CDP_APP_ID, // Subject (App ID)
aud: 'https://api.developer.coinbase.com',
iat: Math.floor(Date.now() / 1000),
exp: Math.floor(Date.now() / 1000) + 3600,
wallet_address: userWallet,
scope: 'onramp:write'
};
const token = jwt.sign(payload, privateKey, { algorithm: 'HS256' });
Why This Was Complex: Coinbase CDP requires server-side JWT generation because:
- Private keys cannot be exposed to client-side code
- JWT must be signed with the exact algorithm and payload structure
- Session tokens are generated using these JWTs for secure onramp sessions
�� CDP Integration
- Session Token API:
/onramp/v1/token
endpoint for secure session creation
- Onramp URL Generation: Dynamic URL creation with user-specific parameters
- Fallback System: Graceful degradation when CDP services are unavailable
🔗 Blockchain Integration (Planned)
- Smart Contracts: Solidity contracts for automated swaps
- Uniswap V3: Integration with Celo's Uniswap deployment
- Gas Optimization: Batch transactions to minimize user costs
��️ Development Tools & Testing
- Multiple Test Files: Created dedicated HTML files for debugging:
test-backend.html
: Comprehensive backend testing
test-simple.html
: Basic connectivity verification
test-multiple-urls.html
: Network interface testing
- Logging System: Extensive console logging for debugging JWT and API flows
- Error Handling: Graceful fallbacks and user-friendly error messages
🔧 Technical Challenges & Solutions
Challenge 1: "Invalid sessionToken" Error
Problem: CDP API rejected client-side generated tokens
Solution: Implemented backend JWT generation with proper private key signing
Challenge 2: Network Connectivity Issues
Problem: Frontend couldn't connect to backend despite working terminal calls
Solution: Modified server to listen on 0.0.0.0
instead of just localhost
Challenge 3: CORS Configuration
Problem: Browser blocking cross-origin requests
Solution: Comprehensive CORS setup with multiple allowed origins and methods
📦 Technologies Used
Frontend
- React 18: Modern component-based UI framework
- Vite: Fast build tool with HMR
- CSS3: Modern styling with gradients and animations
Backend
- Node.js: JavaScript runtime for server-side logic
- Express.js: Web framework for API endpoints
- jsonwebtoken: JWT generation and validation
- CORS: Cross-origin resource sharing middleware
APIs & Services
- Coinbase CDP: Fiat onramp infrastructure
- JWT Authentication: Secure API access
- REST APIs: Standard HTTP communication
Development Tools
- Git: Version control with detailed commit history
- npm: Package management for both frontend and backend
- ESLint: Code quality and consistency
🚀 Deployment & Infrastructure
- Port Management: Frontend (3000), Backend (3002)
- Environment Configuration: Separate config files for development
- Process Management: Background process handling for backend services
🔒 Security Features
- Private Key Protection: Server-side only, never exposed to client
- JWT Expiration: 1-hour token validity
- Input Validation: Sanitized user inputs
- CORS Restrictions: Controlled cross-origin access
📊 Performance Optimizations
- Lazy Loading: Component-based code splitting
- Efficient State Management: Minimal re-renders
- Optimized Build: Vite's fast build process
- Network Optimization: Proper interface binding for backend
🔄 Future Enhancements
- Smart Contract Integration: Automated CELO → cCOP swaps
- ENS Resolution: Human-readable wallet addresses
- Mobile App: React Native version for mobile users
- Multi-Chain Support: Expansion to other blockchains
This project demonstrates real-world DeFi application development with enterprise-grade security, proper error handling, and a focus on user experience. The technical complexity lies in bridging traditional financial infrastructure (credit cards) with decentralized systems while maintaining security and compliance standards.