{"id":7382,"date":"2020-01-03T16:38:46","date_gmt":"2020-01-03T14:38:46","guid":{"rendered":"https:\/\/forklog.media\/?p=7382"},"modified":"2020-01-20T01:57:19","modified_gmt":"2020-01-19T23:57:19","slug":"what-is-atomic-swap","status":"publish","type":"post","link":"https:\/\/forklog.com\/en\/what-is-atomic-swap\/","title":{"rendered":"What Is Atomic Swap?"},"content":{"rendered":"<div id=\"cards_wrapper\">\n<div class=\"single_card\">\n<p id=\"card_counter_1\" class=\"card_counter\"><span class=\"card_counter_span\">1<\/span><\/p>\n<p><strong>What is an atomic swap?<\/strong><\/p>\n<div class=\"card_description\">\n<p style=\"text-align: left;\">An atomic swap is an operation of trading one cryptocurrency for another instantly without a third party, such as an exchange. As a result, the deal is controlled only by the parties involved.<\/p>\n<p style=\"text-align: left;\">Atomic swaps can be conducted either on-chain (i.e. directly between blockchains of two different cryptocurrencies) or off-chain (i.e. outside of blockchain). The first atomic swap <a href=\"https:\/\/twitter.com\/decredproject\/status\/910224860625780736\">took place<\/a> on September 19th, 2017, between Decred and Litecoin blockchains.<\/p>\n<\/div>\n<\/div>\n<div class=\"single_card\">\n<p id=\"card_counter_2\" class=\"card_counter\"><span class=\"card_counter_span\">2<\/span><\/p>\n<p><strong>Why are atomic swaps necessary?<\/strong><\/p>\n<div class=\"card_description\">\n<p style=\"text-align: left;\">The process of exchanging cryptocurrencies on specialized platforms can be time-consuming and involves relatively high fees. Not all platforms support every coin and the required pairs, so a trader willing to exchange one asset for another has to make extra conversions.<\/p>\n<p style=\"text-align: left;\">By 2013 the idea of atomic swaps <a href=\"https:\/\/bitcointalk.org\/index.php?topic=193281.msg2003765#msg2003765\">came about<\/a> as a solution to both the problem of exchange accessibility and the problem of trusting a third party.<\/p>\n<\/div>\n<\/div>\n<div class=\"single_card\">\n<p id=\"card_counter_3\" class=\"card_counter\"><span class=\"card_counter_span\">3<\/span><\/p>\n<p><strong>How does it work in theory?<\/strong><\/p>\n<div class=\"card_description\">\n<p style=\"text-align: left;\">Atomic swaps are conducted using Hashed Timelock Contracts (<a href=\"https:\/\/en.bitcoin.it\/wiki\/Hashed_Timelock_Contracts\">HTLC<\/a>). As the name implies, HTLC is a time-dependant smart-contract that involves generating a cryptographic hash that can be verified by the parties of the deal.<\/p>\n<p style=\"text-align: left;\">HTLC requires the recipient of the transaction to cryptographically confirm that the funds are received. Otherwise, the transaction is deemed invalid and the funds go back to the sender.<\/p>\n<\/div>\n<\/div>\n<div class=\"single_card\">\n<p id=\"card_counter_4\" class=\"card_counter\"><span class=\"card_counter_span\">4<\/span><\/p>\n<p><strong>How does it work in practice?<\/strong><\/p>\n<div class=\"card_description\">\n<p style=\"text-align: left;\">Alice has 100 LTC, which she wants to exchange for an equivalent amount of BTC. The traditional mechanism implies that Alice should go to an exchange, replenish her balance and make an order for selling her LTC. In case of an atomic swap, Alice can exchange her LTC directly into BTC, that are owned by Bob.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/forklog.com\/wp-content\/uploads\/atomicswap-diagram.jpg\" \/><\/p>\n<p style=\"text-align: left;\">As an initiator of the transaction, Alice creates a contract address, which is similar to a bank deposit cell. This address holds Alice\u2019s LTC during the swap process. Unlocking the address requires Bob\u2019s signature and a number generated by Alice. It is important that Alice doesn\u2019t share this number with Bob yet, because it would allow him to withdraw all the funds before the swap is completed.<\/p>\n<p style=\"text-align: left;\">At the next step, Alice comes up with a secret number and generates a hash from it. This hash acts as a lock, while the secret number is the key. Alice sends Bob the hash. Bob views Alice\u2019s contract address, checks if everything is right, and then creates his own address with the same key. He is still unable to unlock the address without Alice\u2019s signature.<\/p>\n<p style=\"text-align: left;\">Now Alice has the key and can sign Bob\u2019s cell, effectively withdrawing the funds. Subsequently, Bob receives the secret number and uses it to unlock Alice\u2019s cell and collect his funds.<\/p>\n<p style=\"text-align: left;\">HTLC structures the transaction in such a way that a successful completion depends on both parties. If a deal is somehow interrupted or cancelled, after a set amount of time all funds will return to their owners.<\/p>\n<\/div>\n<\/div>\n<div class=\"single_card\">\n<p id=\"card_counter_5\" class=\"card_counter\"><span class=\"card_counter_span\">5<\/span><\/p>\n<p><strong>Is Lightning Network necessary for atomic swaps?<\/strong><\/p>\n<div class=\"card_description\">\n<p style=\"text-align: left;\">Lightning Network is not a required condition for atomic swaps, but it can simplify the procedure.<\/p>\n<p style=\"text-align: left;\">Similar to atomic swaps, Lightning Network technology uses Hashed Timelock Contracts. Yet, while atomic swaps connect blockchains, Lightning Network connects payment channels. It means that Alice and Bob open a payment channel with Caroll and exchange funds via this intermediary without needing to trust Caroll.<\/p>\n<p style=\"text-align: left;\">Since Lightning Network and atomic swaps use the same basic mechanism, these two technologies can be integrated easily. As a result, different Lightning Networks can be connected to each other in different blockchains. A swap participant that opens payment channels on both blockchains can act as a payment processor or a decentralized altcoin exchange.<\/p>\n<\/div>\n<\/div>\n<div class=\"single_card\">\n<p id=\"card_counter_6\" class=\"card_counter\"><span class=\"card_counter_span\">6<\/span><\/p>\n<p><strong>What is the difference between on-chain and off-chain swaps?<\/strong><\/p>\n<div class=\"card_description\">\n<p style=\"text-align: left;\">On-chain atomic swaps occur directly in the blockchains of the cryptocurrencies being swapped. These two blockchains have to support HTLC and use the same hashing algorithm.<\/p>\n<p style=\"text-align: left;\">Off-chain atomic swaps are an extension of Lightning Network that allows users to swap coins outside of a blockchain.<\/p>\n<\/div>\n<\/div>\n<div class=\"single_card\">\n<p id=\"card_counter_7\" class=\"card_counter\"><span class=\"card_counter_span\">7<\/span><\/p>\n<p><strong>Which cryptocurrencies support atomic swaps?<\/strong><\/p>\n<div class=\"card_description\">\n<p style=\"text-align: left;\">First successful atomic swaps took place between Litecoin and Decred blockchains, and Vertcoin and Bitcoin. These instances were probably the main reason behind the community interest in the technology. However, atomic swaps are not limited to the aforementioned cryptocurrencies.<\/p>\n<p style=\"text-align: left;\">In order to conduct atomic swaps in their initial implementation, one would need to download the blockchains of both cryptocurrencies in question. For an average user, the process is complicated and impractical.<\/p>\n<p style=\"text-align: left;\">However, better solutions are already being implemented.<\/p>\n<p style=\"text-align: left;\">Komodo is developing a decentralized exchange BarterDEX. They had successfully conducted an atomic swap via Electrum server, that allows for interaction with cryptocurrency without downloading its entire blockchain. Moreover, Komodo <a href=\"https:\/\/komodoplatform.com\/komodo-now-covers-atomic-swaps-between-95-of-all-coins-in-existence\/\">claims<\/a> that connecting Ethereum and Bitcoin blockchains and implementing ERC-20 token allowed BarterDex to support p2p-swaps between 95% of the existing coins and tokens.<\/p>\n<p style=\"text-align: left;\">Among other notable projects working on atomic swap implementation are: Blocknet, which develops \u201cinternet of blockchains\u201d based on Xbridge technology; Altcoin.io, working on a Plasma-based decentralized exchange and a wallet with atomic swap features <a href=\"https:\/\/atomicwallet.io\/\">Atomic Wallet<\/a>.<\/p>\n<p style=\"text-align: left;\">There are specialized websites allowing users to monitor how far away certain cryptocurrencies are from implementing atomic swaps. One of those is <a href=\"https:\/\/swapready.net\/\">swapready.net<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1 What is an atomic swap? An atomic swap is an operation of trading one cryptocurrency for another instantly without a third party, such as an exchange. As a result, the deal is controlled only by the parties involved. Atomic swaps can be conducted either on-chain (i.e. directly between blockchains of two different cryptocurrencies) or [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":7388,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"select":"1","news_style_id":"","cryptorium_level":"","_short_excerpt_text":"","creation_source":"human_written","_metatest_mainpost_news_update":false,"footnotes":""},"categories":[1003],"tags":[325,880],"class_list":["post-7382","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides","tag-lightning-network","tag-swaps"],"aioseo_notices":[],"amp_enabled":true,"views":"288","promo_type":"1","layout_type":"","short_excerpt":"","is_update":"","_links":{"self":[{"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/posts\/7382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/comments?post=7382"}],"version-history":[{"count":7,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/posts\/7382\/revisions"}],"predecessor-version":[{"id":7868,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/posts\/7382\/revisions\/7868"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/media\/7388"}],"wp:attachment":[{"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/media?parent=7382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/categories?post=7382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/tags?post=7382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}