Atomic Swap

Intermediate
Atomic swap is a technology based on smart contracts that enables the exchange of different cryptocurrencies without the need for a centralized market or other intermediaries. Also known as atomic cross-chain trading, atomic swaps involve the trade of one cryptocurrency to another, even if they are running in different blockchain networks.
The concept of an atomic swap was first described in 2013 by Tier Nolan. It was presented as an innovative technique that would allow independent parties to swap cryptocurrency units directly from their addresses (or cryptocurrency wallets). Although Tier Nolan is often acknowledged as the creator of atomic swaps, the idea of performing cross-chain peer-to-peer trades was already being discussed before that. In 2012, Daniel Larimer came up with a trustless exchange protocol called P2PTradeX, which is considered by many as the prototype of atomic swap technology.

One of the main advantages of using atomic swaps is security as users are not required to provide or use their private keys at any point. Another benefit of such technology is related to the fact that there is no need for centralized exchanges, which results in much lower costs (no deposit, withdrawal or trading fees).

Moreover, atomic swaps are resistant to fraud because there is no way for one party to extort the other. Technically speaking, the technology relies on the Hash Timelock Contracts (HTLC) and hash functions. The HTLC smart contracts ensure that the swap either happens in totality or not at all. 
In other words, the contracts are bound to deadlines and require the participants to either settle or cancel the atomic swap within a predefined period of time. Therefore, an atomic swap is only completed if both parties confirm its validity. The confirmation is done through the use of cryptographic hash functions.
For example, say Alice has 5 Bitcoins but wants to trade those for BNBs. Bob, who has BNBs is willing to make the trade. By using atomic swap technology, they are able to perform a peer-to-peer trade without relying on a trusted third-party. This essentially means that two different coins, which are running on separate blockchains, can be traded without any interference.