Seamless Ethereum ↔ XRPL swaps: Extending 1inch Fusion+ with secure hashlock & timelock features
Cross-Chain Atomic Swap Project: USDC on Ethereum to XRP on XRP Ledger This project enables trustless, atomic swaps of USDC on Ethereum for XRP on the XRP Ledger using Hashed Timelock Contracts (HTLCs). This means funds are exchanged directly between users on different blockchains without a central intermediary, ensuring either both sides complete or neither does.
The process unfolds in three phases:
Setup and Secret Generation: The user generates a secret and its hash.
Initiating the Swaps:
The user locks USDC on Ethereum in a smart contract using the hash and a FinishAfter timelock.
A relayer observes this and locks the equivalent XRP on the XRP Ledger using the same hash, an earlier FinishAfter for the user to claim, and a CancelAfter for the relayer's refund if the swap fails.
Claiming and Secret Revelation:
The user claims the XRP on the XRPL by revealing the original secret. This makes the secret public.
The relayer then uses this publicly revealed secret to claim the USDC on Ethereum.
Hashlocks (the hash of the secret) and Timelocks (FinishAfter for claiming, CancelAfter for refunds) are crucial for security and fund recovery. The CancelAfter on the XRPL side is vital for the relayer to reclaim funds if the user doesn't complete their side of the swap within the allotted time, preventing assets from being permanently stuck.
How it's built: Cross-chain atomic swap pipeline using Ethereum + XRP Ledger: Smart Contracts: Solidity contracts on Base Sepolia (Ethereum L2) using Foundry framework XRPL Integration: JavaScript/TypeScript with xrpl.js library for XRP Ledger interactions Crypto-Conditions: five-bells-condition library for XRPL hash time-locked contracts (HTLC) Event-Driven Architecture: Ethereum events trigger off-chain relayer that creates XRPL escrows Hash Time-Locked Contracts (HTLC): Cryptographic primitives enabling trustless cross-chain swaps
Key Technical Details: Deterministic Escrow Deployment: Uses CREATE2 for predictable escrow addresses Crypto-Condition Format: PREIMAGE-SHA-256 for XRPL escrow conditions Real-time Event Monitoring: WebSocket connections to Ethereum for instant event detection Cross-Chain Secret Revelation: Same secret unlocks both Ethereum and XRPL escrows

