To make the exchange, Bob first creates a secret number, a “value.” He then also generates a hash from this value, and he shares this hash with Alice. (But he doesn’t share the value itself!)
Now Bob creates a bitcoin transaction, “locking up” 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.
Right now, Alice can’t claim the bitcoin, because she doesn’t know the secret value, and Bob can’t claim the bitcoin, because two weeks haven’t passed.
Next, Alice creates a litecoin transaction, “locking up” 100 litecoin. The 100 litecoin locked up in this transaction can be unlocked in a follow-up transaction in two ways as well:
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.
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.
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.)
Indeed, Bob can only claim the 100 litecoin if he lets Alice claim her bitcoin: a trustless trade.
The Future of Atomic Swaps
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 Altcoin.io , Atomic wallet and Liquid wallet .
Further Reading: What Are Bitcoin Wallets?
If atomic swaps become widely used, they could play a part in eventually making centralized cryptocurrency exchanges obsolete.
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.