also: Atomic Exchange
1. An atomic swap, or sometimes called atomic cross-chain trading, is the exchange of one [[Crypto (cryptocurrency)|cryptocurrency]] to another cryptocurrency without the need to trust a third party. It’s called atomic (referring to the Greek term atomon, i.e. indivisible) since there aren’t two separate transfers, but one single transfer that does the swap at once.
2. An Atomic Swap or Atomic Exchange, is a type of [[cryptocurrency exchange ]] at an elementary level, where users can exchange currencies from different [[Blockchain|blockchains]] without any kind of intermediary.
2. It is a technique that allows [[Crypto (cryptocurrency)|crypto]] owners to trade one asset for another (on a different [[Blockchain|blockchain]] or [[Off-chain|off-chain]]) without the use of an [[Cryptocurrency Exchange|exchange]], trading platform or middleman.
3. An atomic swap is a [[Peer-to-Peer (P2P)]] exchange of [[Crypto (cryptocurrency)|crypto]] assets between two parties without the use of a trusted third party, such as a centralized exchange. Atomic swaps utilize [[Smart Contract]] to exchange crypto assets between different [[Blockchain|blockchain]] networks through a process of locking, verifying, and unlocking.
4. Atomic swaps involve [[Crypto (cryptocurrency)|cryptocurrencies]] that are tradeable with one another without needing an exchange in the middle. Typically, they have to follow the same encryption standard and have a payment channel [[Protocol(s)|protocol]] such as [[Lightning Network|Lightning Network]]. With what’s called a hash-time locked [[Smart Contract|smart contract]], two individuals can trustlessly trade cryptocurrency pairs with one another: solving the [[Interoperability|interoperability]] piece.
5. An atomic swap is the exchange of one type of [[Crypto (cryptocurrency)|cryptocurrency]] for another—like [[bitcoin (BTC)]] swapped for [[Ethereum (blockchain)]]—without the supervision of a trusted third party. A relatively new notion, cross-chain atomic swapping looks to change the way users transact with one another. In order to prevent one user withholding their agreed upon amount of currency, atomic swaps use [[Hashed Time-Lock Contract (HTLC)|hash time-locked contracts (HTLC)]].
What is an [[Hashed Time-Lock Contract (HTLC)]]?
HTLCs require the recipient of payment to acknowledge their reception of payment prior to a deadline by generating a [[Cryptography|cryptographic]] proof of payment. If they do not do this, they risk losing the rights to claim payment, which would return the payment back to the sender.
6. Traditionally, in order to buy or sell a [[Crypto (cryptocurrency)]], a user is required to use a centralized exchange. This arrangement has several drawbacks: both parties must find an [[Cryptocurrency Exchange|exchange]] they trust, exchanges often suffer downtime during periods of high demand, and exchanges are subject to state oversight.
By contrast, an atomic swap enables direct wallet-to-wallet trading between two peers, using a specially designed smart contract in place of an exchange.
Atomic swaps are based on hash timelock contracts (HTCLs). Every HTCL includes a HashLock, which can be used to lock and unlock the deposited currency with a key available only to the depositor, and a [[TimeLock]], which automatically returns funds to the depositor if the transaction is not completed within a set timeframe.
In an example scenario, Party A creates an HTCL address and deposits their cryptocurrency. A passcode is then created, along with a hash of that code. Party A sends the hash to Party B, who uses it to generate an address. Party B deposits their cryptocurrency with that address. Because Party A has the passcode used to generate the hash, they can access the coins deposited by Party B.
At this point, the contract sends the passcode to Party B, who uses it to access the coins deposited by Party A. If the contracts are not signed within the specified timeframe, both deposits are automatically returned to the relevant depositor.
Atomic swaps can be used to trade on-chain between different [[blockchains]] with different native [[Coin(s)|coins]], or [[Off-chain|off-chain]] using offshoots of the main blockchains in question. Off-chain atomic swaps offer significantly improved [[Transactions Per second (TPS)|transaction speeds]], but they have not yet been fully developed.