{"id":18502,"date":"2020-08-17T04:00:00","date_gmt":"2020-08-17T04:00:00","guid":{"rendered":"http:\/\/ci027d0396100026c3"},"modified":"2025-02-26T08:12:19","modified_gmt":"2025-02-26T13:12:19","slug":"what-are-atomic-swamps","status":"publish","type":"post","link":"https:\/\/bitcoinmagazine.com\/guides\/what-are-atomic-swamps","title":{"rendered":"What Are Atomic Swaps?"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><figure><img decoding=\"async\" src=\"https:\/\/bitcoinmagazine.com\/wp-content\/uploads\/2024\/11\/btc101-whatareatomicswaps.png\" title=\"\"><\/figure>\n<p>Atomic swaps are a peer-to-peer, trustless method of exchanging coins on different blockchains. In essence, atomic swaps allow you to exchange, for example, bitcoin with litecoin, while avoiding the need to trust an exchange or any other third party.<\/p>\n<p><a href=\"https:\/\/bitcoinmagazine.com\/what-is-bitcoin\"><strong><em>Further Reading: What Is Bitcoin?<\/em><\/strong><\/a><\/p>\n<p>Atomic swaps can be performed in one of two ways: Firstly, atomic cross-chain trading can be done directly between two blockchains with different native coins \u2014 known as an on-chain atomic swap. Secondly, you can use off-chain channels that are offshoots of the main blockchains involved \u2014 known as off-chain atomic swaps.<\/p>\n<p>On-chain atomic swaps provide more security since the mechanism is embedded into the blockchain itself and the transaction will either finalize or be cancelled. On the other hand, off-chain atomic swaps are faster and provide more throughput than on-chain atomic swaps but are more complex to perform and still a few years away from practical implementation.<\/p>\n<p><a href=\"https:\/\/bitcoinmagazine.com\/glossary\/what-is-blockchain\"><strong><em>Further Reading: What Is a Blockchain?<\/em><\/strong><\/a><\/p>\n<h2>A Brief History of Atomic Swaps<\/h2>\n<p>Also known as atomic cross-chain trading, the idea of atomic swaps has been around since July 2012, with Sergio Demian Lerner\u2019s initial attempt at creating a trustless exchange protocol called <a href=\"https:\/\/bitcointalk.org\/index.php?topic=91843.0\" target=\"_blank\" rel=\"noopener\">P2PTradeX<\/a>. The idea was further refined and <a href=\"https:\/\/bitcointalk.org\/index.php?topic=193281.msg2003765#msg2003765\" target=\"_blank\" rel=\"noopener\">formalized<\/a> by Tier Nolan in May 2013.<\/p>\n<p>Nolan\u2019s algorithm was refined even further by former Bitcoin developer Mike Hearn and others. Their improved approach allowed the direct exchange of coins on Bitcoin-derived blockchains, without specific support from the protocol.<\/p>\n<p>A successful mechanism to carry out Nolan\u2019s formal description of an atomic swap did not occur until 2014, when the developer jl777 carried out a test for swapping litecoin with dogecoin. Decred later simplified the code to make atomic swaps more widely available, <a href=\"https:\/\/bitcoinmagazine.com\/articles\/decred-adds-atomic-swap-support-exchange-free-cryptocurrency-trading\">successfully executing an atomic swap with litecoin<\/a> in September 2017.<\/p>\n<p>The first bitcoin-to-litecoin off-chain atomic swap using the Lightning Network was conducted in November 2017. These off-chain atomic swaps are largely just demonstrations at the moment and have only been exhibited with two coins that support the same Lightning specification, namely BOLT.<\/p>\n<p><a href=\"https:\/\/bitcoinmagazine.com\/guides\/what-is-an-altcoin\"><strong><em>Further Reading: What Is an Altcoin?<\/em><\/strong><\/a><\/p>\n<h2>How Do Atomic Swaps Work?<\/h2>\n<p>Let\u2019s say Alice and Bob want to exchange one bitcoin for 100 litecoin. Alice has one bitcoin and prefers 100 litecoin; Bob has 100 litecoin and prefers one bitcoin.<\/p>\n<p>To make the exchange, Bob first creates a secret number, a \u201cvalue.\u201d He then also generates a hash from this value, and he shares this hash with Alice. (But he doesn\u2019t share the value itself!)<\/p>\n<p>Now Bob creates a bitcoin transaction, \u201clocking up\u201d one bitcoin. This bitcoin can be claimed in a follow-up transaction in two ways. Either, it can be claimed by Alice, with her signature, in combination with the secret value. The Bitcoin network will recognize the secret value if it matches the hash, which is included in this transaction. Or, it can be claimed by Bob, with his signature, but only after two weeks have passed.<\/p>\n<p>Right now, Alice can\u2019t claim the bitcoin, because she doesn\u2019t know the secret value, and Bob can\u2019t claim the bitcoin, because two weeks haven\u2019t passed.<\/p>\n<p>Next, Alice creates a litecoin transaction, \u201clocking up\u201d 100 litecoin. The 100 litecoin locked up in this transaction can be unlocked in a follow-up transaction in two ways as well:<\/p>\n<p>Either, it can be claimed by Bob, with his signature, in combination with the secret value. Or, it can be claimed by Alice, with her signature, but only after a week has passed.<\/p>\n<p>This means that Bob can now claim the 100 litecoin: He does know the secret value. He just needs to do it within a week, because after that week Alice can claim her 100 litecoin back.<\/p>\n<p>Now, if Bob does claim the 100 litecoin with a follow-up transaction, he broadcasts the secret value: it is now included in the Litecoin blockchain. So, if Alice keeps an eye on the Litecoin blockchain, she can just take the secret value, and, in turn, use it to claim the bitcoin on the Bitcoin blockchain. (She just needs to do it within two weeks, before Bob can claim his bitcoin back.)<\/p>\n<p>Indeed, Bob can only claim the 100 litecoin if he lets Alice claim her bitcoin: a trustless trade.<\/p>\n<h2>The Future of Atomic Swaps<\/h2>\n<p>As the technology of atomic swaps matures, we should see increased adoption among decentralized exchanges and wallets. At this point, we are already starting to see some uptake of atomic swaps, such as with <a href=\"https:\/\/blog.altcoin.io\/atomic-swap-wallet-now-open-sourced-820784cb9d84\" target=\"_blank\" rel=\"noopener\">Altcoin.io<\/a>, <a href=\"https:\/\/atomicwallet.io\/\" target=\"_blank\" rel=\"noopener\">Atomic wallet<\/a> and <a href=\"https:\/\/docs.blockstream.com\/liquid\/swap_tool.html#wallet-compatibility-notice\" target=\"_blank\" rel=\"noopener\">Liquid wallet<\/a>.<\/p>\n<p><a href=\"https:\/\/bitcoinmagazine.com\/guides\/what-are-bitcoin-wallets\"><strong><em>Further Reading: What Are Bitcoin Wallets?<\/em><\/strong><\/a><\/p>\n<p>If atomic swaps become widely used, they could play a part in eventually making centralized cryptocurrency exchanges obsolete.<\/p>\n<p>But first, atomic swaps need to be integrated across existing wallets and services. There also needs to be an improvement in the user experience to make cross-chain trading easy for the average person.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Atomic swaps are a peer-to-peer, trustless method of exchanging coins on different blockchains. In essence, atomic swaps allow you to exchange, for example, bitcoin with litecoin, while avoiding the need to trust an exchange or any other third party. Further Reading: What Is Bitcoin? Atomic swaps can be performed in one of two ways: Firstly, [&hellip;]<\/p>\n","protected":false},"author":2520,"featured_media":18503,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":{"0":"post-18502","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-guides"},"author_data":{"id":2520,"name":"Bitcoin Magazine","nicename":"bitcoin-magazine","avatar_url":"https:\/\/bitcoinmagazine.com\/wp-content\/uploads\/2025\/01\/bitcoin-magazine-logo.jpeg"},"featured_image_url":"https:\/\/bitcoinmagazine.com\/wp-content\/uploads\/2024\/11\/btc101-whatareatomicswaps.png","_links":{"self":[{"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/posts\/18502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/users\/2520"}],"replies":[{"embeddable":true,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/comments?post=18502"}],"version-history":[{"count":0,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/posts\/18502\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/media\/18503"}],"wp:attachment":[{"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/media?parent=18502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/categories?post=18502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/tags?post=18502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}