Currently, while getting crypto coins via centralized exchanges, buyers have to trust the platform that the transaction takes place without complications and funds do not get lost. Also, traders have to trust their private keys to exchanges in order to get access to platforms.

In this case, exchange serves as a third party in transactions as buying and selling crypto takes place through different platforms. However, the so-called Atomic Swap is a solution to this issue.

How Do Atomic Swaps Work?

First, Atomic Swap is the swap, or trade, between cryptocurrencies which takes place instantly and in a P2P manner. It means that for an Atomic Swap, no middleman is needed, and the trading becomes safer and more efficient.

For instance, when two holders of different coins decide to exchange, they do not have to turn to any exchange platforms or escrow services. Traders can also be sure that they will not be cheated by each other if somebody from them does not send money.

How to Use Atomic Swaps?

Similar to LN transactions, Atomic Swap utilizes a hashed timelock contract (HTLC) – the contract with the multisignature transaction system. Timelock ensures that if the trade is not successful, funds will be returned back to users.

Then, a hashlock – a smart contract which locks coins – uses a cryptographic algorithm. It only allows transaction participants to access money when both parties have signed off on their respective transactions.

How to Exchange Coins with Atomic Swap?

One participant creates a random number – preimage. This number serves as the secret passcode. Then, with the use of this number, the second number, hash, is calculated. Hash locks the smart contract, and sent coins can only be accessed if the receiver knows preimage.

The second participant sends a contract for his coins locked with the same used hash. After that, to unlock the funds for first sender, it is important to use the preimage – it turns into the public data, so the second participant can also unlock the funds.

Therefore, it means that the trade only goes successfully for both parties, and both participants receive coins, or the trade does not take place at all.

Problems and Solutions with Atomic Swap

The process looks very safe, however, there might be several complications.

Problem: It is impossible to roll back the swap

If the first sender does not show the preimage to the second one, both contracts will remain locked forever.

Solution: Timelock

Timelock solves the situation, as there can be 24 hours given for the first sender to show preimage to the second one. If it is not done in time, participants get their own money back without trade taking place.

Problem: Revealing preimage little time before timelock ends

If the first sender reveals the preimage to the second one five minutes before the end of timelock, the second participant has little time to unlock his funds, so, they can be stolen.

Solution: Longer timelock for first party

If the refund delay for the first party’s contract is doubled to 48 hours, the second participant will have enough time to unlock his coins.

Which Coins Support Atomic Swaps?

Before using this way of trading, it is important to know what coins have Atomic Swaps possible.

The coins that can be currently exchanged with atomicity are: BTC, BCH, DCR, LTC, MONA, PART, POLIS, VTC, VIA and XZC.

Atomic Swap is the new solution to the exchange problem which still has several difficulties and needs to be tested and upgraded. However, it already presents a safe way of trading without the involvement of third parties.

Crypto coins and trading will be discussed by crypto experts at the Blockchain & Bitcoin Conference Philippines.

Registration >>>