With cryptocurrencies, there are several ways to conduct transactions between parties.
Sending Bitcoin to your friend can be done directly on the blockchain by sending the payment directly to his or her wallet.
However, Bitcoin is known to be relatively expensive and very slow at settling transactions, making it impractical to send small payments through the network.
Furthermore, if that friend prefers a different coin, you would then need to send that Bitcoin to a crypto exchange in order to swap to the desired cryptocurrency.
Atomic swaps aim to simplify and speed up the process of sending cryptocurrency quickly and cheaply.
They can be used in two ways:
One way is to use atomic swaps to conduct transactions between different blockchains.
The other uses them to perform transactions off-chain, thus avoiding the typical fees and confirmation times.
In both cases, atomic swaps are essentially just a smart contract that maintains integrity of transactions and ensures everyone upholds their part of the transaction.
If something goes wrong, the smart contract simply cancels the transaction.
The smart contract performing the atomic swaps is known as the Hashed Timelock Contract (HTLC). As its name suggests, the contract depends on time as the determining factor of the transactions.
Funds are locked in this contract until both parties reach consensus. If the contract has not cryptographically verified that the funds have been received by the recipient within a certain time frame, the transaction will be terminated and funds returned to the sender.
Atomic swaps are still very new to the crypto space but are already promising to provide huge benefits to how we interact with the blockchain on a daily basis. The most prominent application of this technology is in its application to the Lightning Network.