Singularity
Trustless cross-chain autopay via atomic swaps, smart contracts, 1inch & PayPal.
Problem Statement
This project enables trustless cross-chain autopayments using Bitcoin HTLCs and Ethereum smart contracts. It leverages atomic swaps with 1inch routing and supports PayPal’s PYUSD token for recurring payments, creating a secure and automated multi-chain payment system.What We Built We created a revolutionary payment system that solves one of the biggest problems in cryptocurrency: how to make recurring payments between different blockchains. Think of it like setting up automatic bill payments, but for the crypto world, where Bitcoin and Ethereum are completely separate systems that normally can't talk to each other.The Problem We Solved The Cross-Chain Payment Nightmare Imagine you're a business owner who wants to accept Bitcoin payments but needs to pay your suppliers in a stable currency like PayPal's PYUSD. Traditionally, this would require: Manual Conversion: You'd have to manually convert Bitcoin to PYUSD every time Multiple Steps: Bridge Bitcoin to Ethereum, then convert to PYUSD High Fees: Each step costs money and time No Automation: You can't set up automatic recurring payments Technical Complexity: Requires deep knowledge of both Bitcoin and EthereumWhy This Matters Businesses need predictable, automated payment systems Consumers want to pay with their preferred cryptocurrency Suppliers need stable, reliable payments The Market needs solutions that work across different blockchains Our Solution: The "Payment Translator" We built a system that acts like a universal translator for cryptocurrency payments. Here's how it works:For Regular Users Pay with Bitcoin: You can pay using Bitcoin from your wallet Receive PYUSD: The recipient automatically gets PYUSD on Ethereum Set and Forget: Create recurring payments that happen automatically No Technical Knowledge: Works through simple commands or a web interfaceFor Businesses Accept Any Cryptocurrency: Customers can pay with Bitcoin, USDC, USDT, or other tokens Get Consistent Payments: All payments automatically convert to PYUSD Automated Billing: Set up subscription services that charge customers automatically Cross-Chain Compatibility: Works regardless of which blockchain the customer usesHow It Works (In Simple Terms) The Magic Behind the Scenes Customer Initiates Payment: Someone wants to pay you with Bitcoin System Creates a "Lock": Your system locks the Bitcoin in a secure way Automatic Conversion: The system automatically converts Bitcoin to PYUSD Payment Delivered: You receive PYUSD on Ethereum, ready to use Recurring Setup: If it's a subscription, the system remembers and repeats this processThe "Atomic" Part The term "atomic" means "all or nothing" - either the entire transaction succeeds, or nothing happens. This prevents situations where: You send Bitcoin, but don't receive PYUSD The conversion fails halfway through Money gets stuck in the system Real-World Applications Subscription Services SaaS Companies: Charge customers monthly in Bitcoin, receive PYUSD Content Creators: Set up Patreon-style recurring payments Gaming Platforms: Monthly subscriptions paid in crypto Business-to-Business Supply Chain: Pay suppliers automatically in stable currency Freelancer Platforms: Automatic payments for completed work API Services: Recurring charges for usage-based services Personal Finance Bill Payments: Automatically pay utilities with Bitcoin Savings Plans: Regular Bitcoin investments converted to stable currency Charity Donations: Recurring donations to causes you support Why We Built This The Market Need Growing Crypto Adoption: More people want to use cryptocurrency for everyday payments Business Integration: Companies need reliable payment systems that work with crypto Cross-Chain Reality: The future is multi-chain, not single-chain Automation Demand: People want "set it and forget it" payment systems Technical Innovation First of Its Kind: No existing solution handles Bitcoin-to-PYUSD recurring payments User-Friendly: Complex blockchain technology made simple Reliable: Built with security and reliability as top priorities Scalable: Can handle thousands of transactions automatically The Impact For Individuals Freedom: Pay with your preferred cryptocurrency Convenience: Set up automatic payments once, never worry again Security: Your money is protected by blockchain technologySimplicity: No need to understand complex blockchain mechanics For Businesses New Revenue Streams: Accept cryptocurrency payments easily Reduced Costs: Lower fees compared to traditional payment processors Global Reach: Accept payments from anywhere in the world Automation: Reduce manual payment processing work For the Ecosystem Bridge Building: Connects different blockchain communities Adoption Driver: Makes cryptocurrency more practical for everyday use Innovation Catalyst: Shows what's possible with cross-chain technology Trust Builder: Demonstrates that complex systems can be made simpleWhat Makes This Special The "Why Now" Factor PayPal Integration: PYUSD is backed by a trusted financial institution Mature Technology: Bitcoin and Ethereum are stable enough for business use Market Readiness: Businesses and consumers are ready for crypto payments Regulatory Clarity: Clearer rules make it safer to build payment systems
Solution
The Nitty-Gritty Details:Core Architecture & Technologies We built a comprehensive cross-chain atomic swap system that bridges Bitcoin and Ethereum ecosystems, with a focus on automated recurring payments using PayPal's PYUSD stablecoin.Multi-Chain Infrastructure Bitcoin Layer: Native Bitcoin HTLC (Hash Time Locked Contracts) using P2SH scripts for secure fund locking Ethereum Layer: Solidity smart contracts for PYUSD escrow and AutoPay functionality Cross-Chain Bridge: Custom TypeScript services handling atomic swaps between chains CLI Interface: Node.js/TypeScript command-line tool for seamless user interactionTechnology Stack Backend Services:Node.js + TypeScript: Core runtime with full type safety Express.js: REST API for swap management and AutoPay operations PostgreSQL: Database for transaction tracking and subscription management Web3.js/Ethers.js: Ethereum blockchain interaction Bitcoin Core RPC: Direct Bitcoin network communication Smart Contracts:Solidity: AutoPay contract with sophisticated recurring payment logic OpenZeppelin: Security libraries for ERC20 token handling Hardhat: Development and deployment framework Frontend:Next.js: React-based web interface Tailwind CSS: Modern, responsive UI styling Web3 Integration: Wallet connection and transaction signing 3. The Hacky & Notable Solutions A. Custom Bitcoin HTLC Script Builder Why This Is Hacky: Most Bitcoin libraries don't support complex conditional scripts. We built a custom script builder that handles the intricate logic for secret revelation vs. timeout refund, manually constructing the bytecode.B. Cross-Chain Payment Enforcement System // Our solution to enforce PYUSD payments regardless of source chain class CrossChainPaymentService { async processPayment(subscription: Subscription) { // Force all payments to route to Ethereum PYUSD const swapParams = createSingularitySwapParams( subscription.srcChainId, // Any source chain subscription.srcTokenAddress, // Any source token subscription.amount, subscription.subscriber ); // Always enforce Ethereum PYUSD destination swapParams.dstChainId = 1; // Ethereum swapParams.dstTokenAddress = PYUSD_ETHEREUM; // PYUSD } } The Hack: We created a "forced conversion layer" that takes any payment (Bitcoin, USDC, USDT, etc.) and automatically converts it to PYUSD on Ethereum. This ensures 100% compliance with our partner's EVM requirement while maintaining user flexibility.C. Universal Secret Management // Custom secret handling that works across both Bitcoin and Ethereum class SecretManager { generateSecret(): string { return crypto.randomBytes(32).toString('hex'); }validateSecret(secret: string, hash: string): boolean { const computedHash = crypto.createHash('sha256').update(secret).digest('hex'); return computedHash === hash; }} Why This Is Clever: Bitcoin and Ethereum handle secrets differently (raw bytes vs. hex strings). We built a universal converter that works seamlessly across both networks.Partner Technology Integration 1inch Fusion+ Integration Benefit: Eliminates the need for users to manually bridge tokens between chains Implementation: We leverage their cross-chain swap infrastructure to automatically convert any source token to PYUSD on Ethereum Result: Users can pay with Bitcoin, USDC, USDT, or any supported token, and it automatically becomes PYUSD PayPal PYUSD Integration Benefit: Provides a stable, widely-accepted settlement token Implementation: All payments are forced to convert to PYUSD on Ethereum Result: Consistent value across all payment sources Ethereum as Settlement Layer Benefit: Offers the most liquid and secure environment for final settlement Implementation: All cross-chain payments converge to Ethereum Result: Unified payment destination regardless of sourceThe AutoPay Smart Contract We built a time-based payment system that automatically executes recurring payments without requiring user intervention, while maintaining security through time locks and balance validation.The Result Our system now handles:Any source chain/token → Ethereum PYUSD Non-EVM subscriptions → EVM-compliant payments (seamless bridge) This creates a unified payment system where users can subscribe from any supported blockchain with any token, but all payments automatically converge to PYUSD on Ethereum, meeting our partner's requirements while maintaining maximum user flexibility.The Bottom Line: We built a "payment router" that takes the complexity out of cross-chain payments while ensuring 100% compliance with EVM requirements, making it possible for users to pay with Bitcoin and have it automatically become PYUSD on Ethereum.
Hackathon
ETHGlobal New Delhi
2025
Prizes
- 🏆
Utilize 1inch APIs
1inch
Contributors
- PrathmeshRanjan
5 contributions