When I was a kid, I used to collect YuGiOh cards. Everytime my parents went to the store to get groceries, which was probably once a week, I would ask them to get me a pack of YuGiOh cards. Over time, I actually had collected quite the deck. Naturally, going to school and an after-school program that was essentially middle school daycare, I met other kids who also collected YuGiOh cards. One of the things about these cards was they were a lottery, so when you got a pack, you would randomly get a bunch of different cards. Some were common, others rare, and others seemingly didn’t even exist. So we would meet, and we would trade these cards, maybe I had a bunch of common cards and would trade them for a more rare card, or maybe I would trade a rare card that I had 2 of for another rare card, and this trading was super simple, fast, and I didn’t have to worry about someone stealing my cards. This is quite the intro for a video of atomic swaps, but you’ll understand in a bit.
Similar to me wanting to swap my cards, you may have some cryptocurrencies coins or tokens that you wish to swap to another coin or token. Let’s go over the current way to do that, using a centralized exchange like Coinbase.
Bitcoin to Litecoin on Coinbase
First you must sign up to Coinbase. This is a lengthy process, because they want all the KYC information, this means you have to send them your social security number, possibly pictures of yourself, your home address, your phone number, they basically want to identify you even more than your accountant does.
Next, if you have some bitcoin, you have to deposit it onto their exchange. This is bad for two reasons… one is you have to pay a transaction fee of like $10 and then you have to also deposit into a wallet they have access to. This means you have to trust they won’t steal your crypto.
Next, you have to sell your Bitcoin on their exchange for Cash. Coinbase usually takes a fee at this point, since you are using them to sell your Bitcoin. Now, you can use your new cash to buy Litecoin.
Of course, there’s a buying fee too, so Coinbase is really making decent chump change on you doing all of this. Finally, to keep it safe, you have to transfer your litecoin from Coinbase to your own personal wallet, which takes another network fee, but isn’t as much as transferring bitcoin. So that’s a lot, it’s actually a long process, with lots of fees, and you inherently have to trust Coinbase with your tokens. Now let’s go onto how Atomic swaps work.
Bitcoin to Litecoin Atomic Swap
So an atomic swap uses a third party very similar to a smart contract, but here’s how it works. You put in some bitcoins to this third party written by code, and then someone else puts in their litecoin. At this point, you’ve already both agreed to how much you want to trade, so it’s non-negotiable. So you lock your coins into a locked box and give it to this other person. Then they lock their coins into a locked box and give it to you. When this transaction happens, someone gets the key to unlock their box. As soon as they do, the other person gets the key and now you both have swapped tokens.
Atomic swaps are great for many reasons. First off, there is no room for human error. For example, if you deposit your coins into Coinbase, coinbase could get hacked and you could lose your coins in that hack.
Next, the fees are extremely low, there’s no crazy transaction fees, and the waiting time is very short compared to using a central exchange. On top of those reasons, you also don’t need to give up any personal information, no SSN or profile pic or your dog’s left leg. This is actually why Atomic swaps work, they do a great job of allowing users to swap their tokens.
What does Atomic mean?
Atomic in the computer science word means “exactly as planned, or won’t happen at all”. So in the case of an atomic swap, it means that the swap will only happen if both parties do exactly what they said they would do - which is to send their coins to the intermediary.
An example of a non-atomic swap would be to send your coins to a stranger who said they would give you their coins… and “hoping” that they do. The atomic part essentially gets rid of the risk involved with swapping your coins.
How does an Atomic Swap work?
Let’s get into the nitty gritty of how Atomic swaps actually work. They use what is called a “Hashed Time Lock Smart Contract”, which means the funds that are deposited aren’t accessible until both users have submitted their funds. If someone, or even if both parties don’t submit their funds… then the users will eventually get their money back when the time-locked part is up. If you don’t know what a smart contract is, you definitely need to check out our video on them because they are the foundation of decentralized Finance.
There are limits to atomic swaps though. In general, both cryptocurrencies should have the same hashing algorithm and also support similar smart contracts. Just following these rules, it greatly limits which coins and tokens can be swapped, but Atomic swaps are very new and progress is being made every day.
So in short, atomic swaps are a great tool to move your money in crypto from one place to another, but they are also limited in today’s technology. I would love to see how they change, adapt, and evolve to fit in the future, but we are simply an explanation channel here to teach, so you’ll have to subscribe to our Youtube channel if you want any updates.