XChains
  • 💡Introduction
  • Understanding XChains
    • Getting Started
    • Actors
      • Liquidity Providers
      • Swappers
      • Bridgers
    • 9CP (IXCP)
  • How it works
    • Technology
    • Fees
    • Govenance
    • Tokenomics
  • Roadmaps
    • Product Roadmap
    • Business Roadmap
  • One-page Pitch Deck
  • 🏛️XChains Architecture
    • Design Strategy
    • Hashed Time-Locked Contracts (HTLCs)
    • Cross-chain Communication
      • Oracle
      • Relay Network
  • 🛠️XChains Implementation
    • Smart Contracts
      • Private Liquidity Pool Contracts
      • Bridge Contracts
    • Atomic Swap Protocol
    • Cross-Chain Transfer Flow
    • Security Considerations
    • Public Pool Integration
  • 🔐XChains Liquidity
    • Private Liquidity Pools
    • Shared Liquidity Pools
    • XChains Formula
  • 📬Contact Us
    • Email
    • Website
    • Telegram Channel
    • Telegram Chat
Powered by GitBook
On this page
  1. XChains Implementation

Atomic Swap Protocol

The technique allows direct peer-to-peer exchanges between users across different chains

Atomic swaps allow two parties to exchange assets across different blockchains without trusting a third party, and transactions are either completed in their entirety or not at all.. This can be achieved using hashed time-locked contracts (HTLCs).

How It Works:

  1. Initiate Swap:

    • User A on Chain A wants to swap Token 1 for Token 2 with User B on Chain B.

    • User A locks Token 1 in an HTLC on Chain A.

    • User B locks Token 2 in an HTLC on Chain B.

  2. Hash Preimage:

    • Both HTLCs are created with the same hash lock and time lock.

    • User A generates a secret (preimage) and hashes it. The hash is shared with User B.

  3. Redeem Tokens:

    • User B can unlock Token 1 on Chain A using the preimage.

    • Once User B reveals the preimage, User A can use it to unlock Token 2 on Chain B.

  4. Fallback Mechanism:

    • If the swap is not completed within a specified time, both HTLCs expire, and the tokens are returned to their original owners.

This mechanism ensures that tokens are directly swapped atomically between private pools without needing shared pools.

PreviousBridge ContractsNextCross-Chain Transfer Flow

Last updated 11 months ago

🛠️