Bitcoin
Bitcoin CPI
Venture Portfolio
Funds
Market Insights
Indicators
About
Contact
August 7, 2023





Atomic swaps are an innovative technology that enables decentralized cross-chain crypto asset trading. Read on to learn what Bitcoin atomic swaps are and how they work.
Cross-chain atomic swaps enable two parties to trade digital assets from different blockchains without a trusted centralized intermediary.
More precisely, Bitcoin atomic swaps are automated contracts that allow two individuals to trade assets between the Bitcoin blockchain and other blockchains. Bitcoin atomic swaps can also be carried out between the Bitcoin network and the Layer-2 networks built on top of it.
Atomic swaps are grouped into two categories: on-chain and off-chain.
The concept of cross-chain atomic swaps was initially proposed by Sergio Demian Lerner in 2012. Tier Nolan later described the same idea but introduced a different implementation method in 2013. It was not until 2017 that the first successful actualization of atomic swaps took place between LTC and BTC. In this first atomic swap transaction, it was Litecoin’s founder Charlie Lee who exchanged 10 LTC for 0.1167 BTC.
While this was a breakthrough moment, atomic swaps still haven’t exactly caught on. A different cross-chain technology, bridging, has become more popular instead, despite Ethereum’s founder Vitalik Buterin recommending atomic swaps over cross-chain bridges.

Atomic swaps leverage smart contracts, which ensure that predefined conditions are satisfied, and only then a transaction is executed. If both parties or one party fails to meet the set requirements, the transaction is canceled, and the funds are transferred back.
The term “atomic” describes a transaction that either happens or doesn’t at all. There is nothing in between.
Atomic swaps are executed in the personal wallets of the two parties involved. They utilize smart contracts called Hash Timelock Contracts (HTLCs). An HTLC is time-bound and requires both parties to fulfill the preset conditions within a given time frame. Moreover, an HTLC uses a cryptographic hash function that converts data such as transaction details and wallet addresses into a number called a hash.
HTLCs require two encrypted security keys: hashlock and timelock.
Let’s picture a scenario where Jack wants to exchange 2,000 STX for Jill’s equivalent amount of BTC.
Jack sends his STX to the contract address of the HTLC he has created. The contract then generates a unique key for Jack that only he has access to. This key acts as a password that unlocks the STX he has deposited into the smart contract. The contract also uses the key to produce a hashed version of the key that Jack sends to Jill. That means that Jill is in the possession of the hashed form of the password needed to unlock Jack’s STX. She can only confirm that the funds are locked in the contract but can’t access them yet.
Jill then uses the hashed key to generate her own contract address and deposit her BTC. Once funds from the two parties are in the same smart contract, Jack can claim Jill’s BTC.
By unlocking Jill’s contract address, the password is revealed, allowing Jill to claim the deposited STX. Jack can unlock the BTC since he has the password that unlocks the hashed key Jill used to lock her BTC.
LNSwap is a decentralized protocol that enables fast and private P2P swaps between Bitcoin and its Layer-2 network, Stacks. That means users can swap BTC for digital assets on Stacks and vice versa.
LNSwap uses Lightning to reduce transaction fees and increase transaction speeds. The protocol also uses submarine swap technology to make on-chain Bitcoin addresses compatible with off-chain Lightning addresses. As a result, it can facilitate BTC transfers from the Bitcoin blockchain to an off-chain Lightning channel. LNSwap provides Lightning nodes for users that want to open Lightning channels with the protocol.
Like decentralized exchanges (DEXs), LNSwap relies on liquidity providers, who supply the necessary funds to make atomic swaps on the protocol. In return, liquidity providers earn rewards from the transaction fees generated by the trades taking place on the protocol.
Here is how you can swap BTC for STX (Stacks native token) on LNSwap:




Now, let’s take a look at the benefits and drawbacks of cross-chain swaps.
Bitcoin atomic swaps provide an option for fully decentralized trading, an immensely important aspect of Bitcoin-based DeFi. They also bring interoperability to the Bitcoin ecosystem.
Unfortunately, cross-chain atomic swap technology hasn’t really caught on yet because it is complex to build. Additionally, limited liquidity compels atomic swap exchanges to rely on liquidity pools, requiring user participation while creating targets for cyberattacks.
Despite these challenges, Atomic swaps hold a lot of promise and could change the Web3 landscape significantly once its drawbacks are addressed and adoption grows.
Yes. For example, LNSwap is a decentralized protocol that facilitates atomic swaps between Bitcoin and its Layer-2 (L2) network Stacks. This enables users to swap BTC for any of the digital assets on the Stacks network and vice versa.
In other words, LNSwap makes the Bitcoin Layer-1 network interoperable with the Stacks L2 network. Therefore, LNSwap plays a critical role in Bitcoin’s DeFi ecosystem by permitting cross-chain token swaps between Bitcoin and Stacks.
Komodo’s AtomicDEX is another atomic swap for Bitcoin and other blockchain networks. It allows users to trade BTC with the native assets of other L1 chains like LTC, DOGE, and RVN.
During an atomic swap, two individuals’ funds are held in a hash timelock contract and are unlocked when both sides fulfill the preset conditions. So, whenever two people want to swap tokens, a new contract is created to facilitate the trade. However, a decentralized exchange (DEX) holds everyone’s funds in one on-chain contract, creating a honey pot that hackers could exploit.
Atomic swaps are semi-private. While the swap transaction itself is indistinguishable from other transactions, the individual transactions involved in the trade can be traced on the respective public blockchains. Users can boost the privacy of their atomic swaps by using protocols with enhanced privacy like LNSwap. Alternatively, users can swap tokens from two different privacy-focused blockchains to keep their trades private.