what is an atomic swap 
an atomic swap is an exchange of cryptocurrencies from separate blockchains the swap is conducted between two entities without a third party s involvement the idea is to remove centralized intermediaries like regulated exchanges and give token owners total control the term atomic derives from the term atomic state in which a state has no substates it either happens or it doesn t there is no other alternative this refers to the state of the cryptocurrency transaction it happens or it doesn t most atomic swap enabled wallets and blockchains use smart contracts smart contracts are programs within blockchains that execute when certain conditions are met in this case the conditions are that each party agrees to the transaction before a timer runs out using a smart contract in the trade prevents either party from stealing a cryptocurrency from the other atomic swaps are also called cross chain atomic swaps understanding atomic swapseach cryptocurrency is supported by a blockchain designed only to accept transactions in specific tokens for example bitcoin btc has a blockchain and eth ether has another you cannot easily exchange btc and eth without first converting to fiat currency then buying the other another technique is to convert between cryptocurrencies and exchanges multiple times to get the one you want atomic swaps allow you to exchange tokens from different blockchains in one trade decentralized exchanges can conduct atomic swaps for you a decentralized exchange dex has no central authority regulating it it is a platform you can trade on without third parties you can also choose from cross chain swap providers where you transfer your digital assets into another wallet conduct the swap and transfer them back out atomic swaps rely on each party to provide proof through key encryption and acceptance of both parties through the encrypted key the concept was conceived shortly after altcoins cryptocurrencies other than bitcoin materialized the creation of altcoins meant some cryptocurrency owners became interested in moving capital between coins this type of token swap first appeared in september 2017 when an atomic swap between decred and litecoin was conducted 1since then startups and decentralized exchanges have implemented swaps and allowed users the same facility for example lightning labs a startup that uses bitcoin s lightning network for transactions has conducted off chain swaps utilizing the technology 2special cryptocurrency wallets have also been developed that are capable of cross chain atomic swaps liquality has developed a wallet that will swap bitcoin eth and more 3atomic swap processin an atomic swap two token owners agree to exchange their tokens for any amount they agree on the smart contract program sees that they both agreed to it so it executes the trade for them the transaction is recorded in the blockchain and validated by the network nodes and then a new block is opened for another transaction the transaction cannot be reversed both parties must agree to another transaction to exchange the tokens again if they would like them back atomic swaps use hash timelock contracts htlc to automate the exchange of tokens as its name denotes htlc is a time bound smart contract between parties that involves generating one cryptographic hash on each end a cryptographic hash function is an algorithm that converts data of variable length such as a person s wallet address and transaction information it converts it to a hexadecimal number with a fixed length in general the number that is generated is called the hash htlc requires both parties to acknowledge receipt of funds within a specified timeframe if one party fails to confirm the transaction within the timeframe then the entire transaction is voided and funds are returned this eliminates counterparty risk or the risk that one party will accept the offered coins and decline the transfer of their coins for instance suppose jane wants to convert 1 btc to an equivalent number of litecoins with john she submits the transaction through an atomic swap capable wallet a cryptographic hash function generates a hex number to encrypt the transaction during this process the process is repeated at john s end both jane and john unlock their respective funds using their encrypted numbers they have to do this within a specified timeframe or the transfer will not occur the htlc within the blockchains then executes the trade 