crossITFKKARnot
Cross-chain payment gateway with 1inch Fusion SDK enabling instant token swaps
Problem Statement
This project is a comprehensive cross-chain payment gateway that enables seamless token exchanges across multiple blockchain networks using 1inch's Fusion SDK. The platform provides both same-chain and cross-chain payment solutions, allowing merchants to accept payments in any supported token while receiving their preferred token on their desired blockchain.Key Features: • Cross-chain payments: Users can pay with tokens on one chain (e.g., WBNB on BSC) while merchants receive different tokens on another chain (e.g., USDC on Ethereum) • Same-chain swaps: Direct token exchanges within the same blockchain network • Multi-chain support: Supports Ethereum, BSC, Polygon, Arbitrum, Optimism, Avalanche, Base, and more • Merchant dashboard: Complete order management system with real-time status tracking • User authentication: Secure JWT-based authentication with email verification • Order history: Comprehensive tracking of all payment transactions • Real-time price feeds: Live USD pricing for accurate payment calculations • Wallet integration: MetaMask and other Web3 wallet support with automatic network switchingThe platform acts as a bridge between different blockchain ecosystems, solving the liquidity and cross-chain interoperability challenges that merchants face when accepting cryptocurrency payments. Merchants can specify their preferred receiving token and chain, while customers can pay with whatever tokens they have available, making crypto payments as seamless as traditional payment methods.
Solution
Technology Stack: • Frontend: React 18 + TypeScript + Vite + Tailwind CSS • Backend: Node.js + Express + TypeScript • Database: MongoDB with Mongoose ODM • Authentication: JWT tokens with HTTP-only cookies • Blockchain Integration: 1inch Fusion SDK v2.3.8 + Cross-chain SDK v1.0.2 • Web3 Libraries: Ethers.js v6 + Wagmi + RainbowKit • Wallet Connection: MetaMask integration with automatic network switching • Deployment: Render cloud platformArchitecture Deep Dive:Cross-Chain Payment Flow:Uses 1inch Fusion SDK's hub-and-spoke model with HashLock mechanismsImplements secret-based atomic swaps for secure cross-chain transfersCreates merkle tree structures for multi-fill ordersAutomatic network switching and token approval handlingState Management:Frontend uses React Context for authentication stateBackend implements order mapping system linking merchant orders to 1inch quotesReal-time order status tracking with automated checker jobsMongoDB stores order history, user data, and payment mappingsSecurity Implementation:JWT authentication with secure HTTP-only cookiesCORS configuration for cross-origin requestsInput validation using Zod schemasRate limiting on API endpointsSecure secret generation for atomic swapsNotable Technical Solutions:a) Cross-Chain Order Validation:Built custom validation layer to ensure order parameters match between frontend and 1inch APIImplements chain ID and token address verificationHandles token balance checking before approvalsb) Price Oracle Integration:Real-time USD price fetching across multiple chainsSupports price calculations for cross-chain value matchingHandles different token decimals and precisionc) Network Management:Dynamic network configuration for 15+ blockchain networksAutomatic RPC endpoint managementFallback mechanisms for network switchingd) Order Lifecycle Management:Creates unique mappings between merchant orders and 1inch quotesImplements background jobs for order status monitoringHandles partial fills and multi-step atomic swapsPartner Technology Benefits:1inch Fusion SDK: Provides best price execution and MEV protection1inch Cross-chain SDK: Enables atomic cross-chain swaps without bridgesMongoDB: Scales seamlessly for order and user managementRender: Provides reliable cloud deployment with automatic scalingHacky/Notable Implementations:Custom proxy middleware that intercepts 1inch API calls to inject merchant order validationDynamic contract address management for Limit Order Protocol across chainsSecret hash generation using browser crypto API for client-side securityAutomatic token approval optimization to prevent unnecessary gas costsEnvironment variable management for seamless local/production deploymentThe project successfully bridges the gap between traditional payment expectations and Web3 capabilities, making cross-chain payments accessible to both merchants and customers without requiring deep blockchain knowledge.
Hackathon
ETHGlobal New Delhi
2025
Contributors
- Pavankumar07s
12 contributions