A. Ahmad An open-minded individual that's enthusiastic about Bitcoin, with all of its freedom and purity that it provides.

How To Make A Crypto Transaction Using Atomic Swaps

2 min read

different crypto transactions illustrated in swaps

As time in the cryptocurrency industry moves forward, so is the focus on having more decentralized methods of exchanging various crypto coins and tokens, be it on the same network or between two different ones, instead of dealing with a centralized exchange, and aside from Escrow type swaps where they’d used a multisig setup to conduct decentralized exchanging, like what we have here on WhalesHeaven, another method of exchanging crypto that’s been gaining traction is what’s known as an Atomic Swap.

What is an Atomic Swap transaction?

An Atomic Swap is a method of exchanging one cryptocurrency with another, both of which are on their own respective blockchain network, without the need of relying on a third entity to handle the transaction.

This kind of exchange is what people would call a decentralized exchange (DEX), and because of its nature, you’d remove the need for trust, as well as not paying any extra fee aside from the ones that you have to pay to conduct the transaction for the exchange when you want to exchange one coin or token from one blockchain network with another different one. An example of this would be Atomic Swapping a Bitcoin with an equivalent amount of Litecoin.

It must be noted that not all blockchains can exchange with each other using Atomic Swaps. Only those that have a UTXO structure can conduct Atomic Swap transactions between each other.

How does an Atomic Swap transaction work?

The best way to describe how it works is through an example. Let’s take Alice and Bob on this test ride. Alice has one Bitcoin and would like to exchange it for Bob’s 250 Litecoin. Alice would create a smart contract and lock/encrypt it using a cryptographic hash, where it can be unlocked using a key that only she knows. Inside the contract, she wrote that one BTC is sent to Bob’s BTC address if the contract has been unlocked by Bob and that if nothing happens within 24 hours, that one BTC would be sent back to Alice’s BTC address. She’d then broadcast that smart contract to the Bitcoin network. This is a type of smart contract that’s known to be called a hashed timelock contract (HTLC).

On Bob’s end, he would do almost the exact same thing as what Alice did, but the difference is that Bob would use the same hash that’s Alice used to lock up her BTC, on his smart contract to lock up his LTC, and he doesn’t know what the key is to unlock it. The other difference is that Bob’s contract would send 250 LTC to Alice’s LTC address if Alice unlocks the contract, or it would be sent back to Bob’s LTC address if nothing happens within 12 hours.

Now that both of these smart contracts are broadcasted within their respective networks, the moment Alice opens the locked smart contract on the Litecoin network using her key, that key would be revealed to Bob and he can use it within the allocated time to open the locked smart contract on the Bitcoin network. In the end, both Alice and Bob have received what they agreed for.

That’s generally how Atomic Swaps work, where “Atomic” in a scientific sense means that it either happens or it doesn’t. This is by far one of the most decentralized ways of conducting cross-chain trading in a decentralized way and removes the need for centralized exchanges in favour of decentralized exchanges/swaps.

Where can you conduct Atomic Swaps?

As mentioned previously, there’s a lot of interest from end-users to various projects to utilize Atomic Swap technology, because of its security with trading various digital assets, and so there’s demand for having such technology and service in various wallets.

One wallet that offers Atomic Swaps is Komodo, a non-custodial cryptocurrency wallet. Aside from wallets, there’s what’s known as Bitcoin side-chains, that allow users to Atomic Swap tokens from them with Bitcoin, with the current popular one being Liquid, where for example you can Atomic Swap BTC for L-USDT. Another similar upcoming Bitcoin side-chain, but one that’s aiming to expand its services, is Mintlayer.

There isn’t much more wallets or blockchains that are focusing on Atomic Swaps, but that’s most likely going to change very quickly in the nearest future.

A. Ahmad An open-minded individual that's enthusiastic about Bitcoin, with all of its freedom and purity that it provides.