Atomic swaps, or atomic cross-chain trading, is the exchange of one cryptocurrency to another cryptocurrency, without the need to trust a third-party.
A relatively new piece of technology, atomic cross-chain trading is looking to revolutionize the way in which users transact with each other. For example, if Alice owned 5 Bitcoins but instead wanted 100 Litecoins, she would have to go through an exchange, i.e. a third-party. However, with atomic swaps, if Bob owned 100 Litecoins but instead wanted 5 Bitcoins, then Bob and Alice could make a trade. In order to prevent, for example, Alice accepting Bob’s 100 Litecoins but then failing to send over her 5 Bitcoins, atomic swaps utilizes what is known as hash time-locked contracts (HTLCs).
Hash time-locked contracts ensure that the atomic swap process is completely trustless by ensuring both fulfill the requirements of the trade. HTLCs require the recipient of a payment to acknowledge receiving payment prior to a deadline by generating a cryptographic proof of payment. Or the recipient risks losing the right to the claim the payment, therefore returning the funds back to the sender.
Therefore, for a trade between Alice and Bob to take place, both must submit their transaction to their respective blockchain, Alice on the Bitcoin blockchain and Bob on the Litecoin blockchain. In order for Alice to claim the 100 Litecoins sent from Bob, she must produce a number that only she knows, used to generate a cryptographic hash, therefore providing proof of payment. Similarly, in order for Bob to claim the 5 Bitcoins that was sent from Alice, he must also provide the same number, that was used to generate the cryptographic hash.