cCOP OnRamp with CDP
Celo Onramp App Fiat to cCOP Bridge Celo Onramp App Fiat to cCOP Bridge
Problem Statement
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.
Solution
📖Description (Detailed)🎯 Project OverviewThis 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 FlowUser Input: User enters COP amount or selects predefined amountsFiat Onramp: Credit card payment processed through Coinbase CDP OnrampAsset Acquisition: User receives CELO tokens on Celo blockchainAutomatic Swap: Backend automatically swaps CELO → USDT → cCOP via Uniswap V3Final Delivery: User receives cCOP in their specified wallet address💡 Key InnovationThe project eliminates the traditional multi-step process where users would need to:Buy crypto with fiatTransfer to a DEXManually swap tokensHandle gas fees and slippageInstead, users get aone-click experiencefrom COP to cCOP, making DeFi accessible to non-technical users in Colombia.🌍 Real-World ImpactFinancial Inclusion: Enables Colombians to access DeFi without crypto knowledgeRemittances: Facilitates cross-border payments with minimal feesStablecoin Adoption: Promotes cCOP usage in the Colombian marketRegulatory Compliance: Uses Coinbase's compliant onramp infrastructure🔧How It's Made (Technical Deep Dive)🏗️ Architecture OverviewThe project uses amicroservices architecturewith clear separation between frontend, backend, and blockchain interactions:Frontend (React) ↔ Backend (Node.js) ↔ CDP APIs ↔ Celo Blockchain��️ Frontend LayerFramework: React 18 with Vite for fast development and HMRState Management: React hooks for local state managementStyling: Custom CSS with modern gradients and responsive designComponents: Modular architecture with reusable components:QuoteDisplay: Shows real-time conversion rates and feesFlowInfo: Visual representation of the COP → CELO → cCOP flowAPITester: Development tool for testing CDP integration⚙️ Backend LayerRuntime: Node.js with Express.js frameworkAuthentication: JWT generation using Coinbase's private key infrastructureAPI Proxy: Acts as middleware between frontend and CDP APIsSecurity: Implements proper CORS, input validation, and error handling🔐 Authentication SystemThe most complex part of the project is theJWT 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 codeJWT must be signed with the exact algorithm and payload structureSession tokens are generated using these JWTs for secure onramp sessions�� CDP IntegrationSession Token API:/onramp/v1/tokenendpoint for secure session creationOnramp URL Generation: Dynamic URL creation with user-specific parametersFallback System: Graceful degradation when CDP services are unavailable🔗 Blockchain Integration (Planned)Smart Contracts: Solidity contracts for automated swapsUniswap V3: Integration with Celo's Uniswap deploymentGas Optimization: Batch transactions to minimize user costs��️ Development Tools & TestingMultiple Test Files: Created dedicated HTML files for debugging:test-backend.html: Comprehensive backend testingtest-simple.html: Basic connectivity verificationtest-multiple-urls.html: Network interface testingLogging System: Extensive console logging for debugging JWT and API flowsError Handling: Graceful fallbacks and user-friendly error messages🔧 Technical Challenges & SolutionsChallenge 1: "Invalid sessionToken" ErrorProblem: CDP API rejected client-side generated tokensSolution: Implemented backend JWT generation with proper private key signingChallenge 2: Network Connectivity IssuesProblem: Frontend couldn't connect to backend despite working terminal callsSolution: Modified server to listen on0.0.0.0instead of justlocalhostChallenge 3: CORS ConfigurationProblem: Browser blocking cross-origin requestsSolution: Comprehensive CORS setup with multiple allowed origins and methods📦 Technologies UsedFrontendReact 18: Modern component-based UI frameworkVite: Fast build tool with HMRCSS3: Modern styling with gradients and animationsBackendNode.js: JavaScript runtime for server-side logicExpress.js: Web framework for API endpointsjsonwebtoken: JWT generation and validationCORS: Cross-origin resource sharing middlewareAPIs & ServicesCoinbase CDP: Fiat onramp infrastructureJWT Authentication: Secure API accessREST APIs: Standard HTTP communicationDevelopment ToolsGit: Version control with detailed commit historynpm: Package management for both frontend and backendESLint: Code quality and consistency🚀 Deployment & InfrastructurePort Management: Frontend (3000), Backend (3002)Environment Configuration: Separate config files for developmentProcess Management: Background process handling for backend services🔒 Security FeaturesPrivate Key Protection: Server-side only, never exposed to clientJWT Expiration: 1-hour token validityInput Validation: Sanitized user inputsCORS Restrictions: Controlled cross-origin access📊 Performance OptimizationsLazy Loading: Component-based code splittingEfficient State Management: Minimal re-rendersOptimized Build: Vite's fast build processNetwork Optimization: Proper interface binding for backend🔄 Future EnhancementsSmart Contract Integration: Automated CELO → cCOP swapsENS Resolution: Human-readable wallet addressesMobile App: React Native version for mobile usersMulti-Chain Support: Expansion to other blockchainsThis project demonstratesreal-world DeFi application developmentwith 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.
Hackathon
ETHGlobal New York 2025
2025
Contributors
- 0xj4an-Work
35 contributions