The Atomic Swap is a method for exchanging or trading your cryptocurrencies very quickly with another person, without an intermediary and trustless directly from your wallet and not from any exchange.
In fact, changing two cryptocurrencies implies that there are costs for using an exchange, plus the costs of handling the coins to which the wasted time such as registering for the exchange and completing all the paperwork. This obviously does not allow us to operate within a few minutes, perhaps making us miss out on interesting opportunities on the market.
With the atomic swap we skip all these problems. Swap means exchange while the term atomic comes from the computer world and implies that an operation is conducted as planned or not conducted at all.
So looking into the details of the exchange, this must happen exactly as we have organized or it will absolutely not happen.
To give you an example of a non-atomic swap, it would be like sending the coins to a stranger hoping that he doesn’t run away or that he sends me the correct coin number we agreed on.
In the atomic swap there is no human error, manipulation or fraud and it only works with crypto and not with fiat currency.
The atomic swap works through the use of smart contracts, since these allow users to avoid fraud by checking that the funds involved in the exchange are really present in the wallets of the two protagonists. These smart contracts are called Hashed Time Lock contracts.
Funds are blocked within smart contracts and can be publicly controlled on the blockchain. These funds can only be unlocked with a key called preimage that matches the hash of this contract.
At any time before the exchange, one of the parties can withdraw and the funds will return free in the wallet of the previous owner.
Atomic swaps aren’t perfect as they have limitations. In fact, exchanges must only be made with coins that support specific types of smart contracts and that have the same algorithm
Some wallets already include this exchange option within them. Learn more about wallet here.
As you can see, atomic swaps can be a useful solution to bypass exchanges when we want to trade particular coins. At the moment it is not possible with all of them and therefore we will still have to go through an exchange.