project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5
project screenshot 6

ThalaivarSwap

ThalaivarSwap: Cross-chain atomic swaps between Ethereum and Polkadot using HTLCs

ThalaivarSwap

Created At

Unite Defi

Project Description

ThalaivarSwap implements a trustless cross-chain atomic swap protocol enabling seamless exchange of assets between Ethereum and Polkadot networks. The system uses Hash Time Locked Contracts (HTLCs) to ensure atomic execution - either both parties receive their desired assets, or the swap fails completely with automatic refunds. The protocol supports bidirectional swaps:

ETH → DOT: Users can swap Ethereum for Polkadot tokens DOT → ETH: Users can swap Polkadot tokens for Ethereum

Key features include:

Trustless Operation: No intermediaries required - smart contracts enforce the swap conditions Atomic Execution: Cryptographically guaranteed that both sides complete or both fail Time-bounded Security: Automatic refunds if swaps don't complete within specified timeframes Cross-chain Coordination: Relayer-based monitoring ensures proper execution across both networks Cryptographic Security: Uses hash locks with secret revelation for secure fund release

The system has been successfully tested with real transactions, demonstrating complete HTLC flows including fund locking, secret coordination, and atomic settlement on both chains.

How it's Made

Core Architecture The project implements a sophisticated cross-chain atomic swap system using Hash Time Locked Contracts (HTLCs) deployed on both Ethereum and Polkadot networks. Technologies Used Ethereum Side:

Solidity Smart Contracts: Core HTLC implementation with functions like createEthToDotOrder, releaseEth, and automatic refund mechanisms OpenZeppelin: Used for security features including reentrancy protection (nonReentrant modifiers) and access control Web3.js/Ethers.js: For blockchain interaction and transaction monitoring

Polkadot Side:

Rust Smart Contracts: Custom FusionHtlc contract implementing HTLC functionality with new_contract(), withdraw(), and refund() methods Substrate Framework: Leveraging Polkadot's parachain architecture Asset Hub Integration: For DOT token management and HTLC settlement

Cross-Chain Infrastructure:

Relayer System: Custom relayer monitors both chains, coordinates secret sharing, and triggers settlement Hash Lock Mechanism: Uses keccak256 hashing for secret verification across both chains Time Lock System: Ethereum uses seconds-based timeouts (3600-604800s), Polkadot uses block-based timeouts (100-14400 blocks)

Technical Implementation Details HTLC Flow Architecture:

Order Creation: User initiates swap by creating HTLC on source chain with secret hash and timelock Cross-Chain Locking: Corresponding HTLC created on destination chain with same secret hash Secret Revelation: When conditions are met, secret is revealed enabling withdrawal on both chains Atomic Settlement: Both sides complete simultaneously or automatic refunds trigger

Notable Technical Achievements Particularly Hacky/Notable Elements:

Cross-Chain Secret Coordination: Implemented a sophisticated mechanism where the same cryptographic secret unlocks funds on both chains, ensuring true atomicity Dual Timelock System: Engineered different timelock mechanisms (seconds vs blocks) to work harmoniously across different blockchain architectures Relayer Resilience: Built fault-tolerant relayer logic that can recover from network issues and ensure swap completion Gas Optimization: Implemented efficient contract interactions to minimize transaction costs while maintaining security

Security Innovations:

Multi-layer protection against common attack vectors including double-spending, reentrancy, and race conditions Automatic refund mechanisms that activate after timelock expiry, ensuring users never lose funds permanently Cryptographic verification system using hash preimages that provides mathematical proof of swap completion

Partner Technology Benefits

Polkadot's Asset Hub: Provided efficient DOT token management and reduced transaction fees for cross-chain operations Ethereum's mature DeFi ecosystem: Enabled integration with existing DEX protocols and wallet infrastructure Substrate's flexibility: Allowed custom HTLC logic implementation tailored specifically for cross-chain operations

background image mobile

Join the mailing list

Get the latest news and updates