7 min read
If you are an expert in the world of cryptocurrencies you have probably heard about Cross-chain Swaps. If you don’t know what they are, don’t worry. In this article we will tell you what they are and how they work.
Cross-chain swaps are a type of Peer-to-Peer exchange that offers users the opportunity to securely transform their cryptocurrencies without the intervention of intermediaries.
These swaps take place between two different cryptocurrencies that are executed on their own blockchains. In less technical words, cross-chain swaps allow users to exchange cryptocurrencies between two peers.
History of Cross-Chain Swaps
The first detailed explanation of what a cross-chain swap was was in the Atomic Cross-Chain Swaps whitepaper published by Maurice Herlihy, a member of the Computer Science Department at Brown University Providence.
This paper was presented during the ACM Symposium 2018. In this paper we were explained in detail what is the functioning of an atomic cross-chain swap. This paper also argued its possibilities and main challenges in the creation of this tool.
According to their whitepaper, what a cross-chain swap does is to bring in money from both parties and place it under a smart contract that ensures that the transaction is only finalized if both parties are satisfied. In addition, the smart contract ensures that if one of the two parties tries to act in bad faith, it does not have control of the funds.
How does a Cross-chain swap work?
To better understand how this mechanism works, let’s put an example into practice. Let’s imagine that a user (A) wants Ethereum (ETH) but has Bitcoin (BTC) and wants to exchange them. On the other side of the world is user (B) who has ETH and wants BTC. Both users want to exchange the currency they have for the currency the other user has, but how could they do that?
Given this unknown, user (A) and user (B) decide to start a process to exchange their cryptocurrencies through a wallet capable of doing so. User (A) takes the first step by creating a transaction with a certain OP CODE and locks the exact amount of BTC that user (B) wants. The script code used by user (A) can only be unlocked when user (B) fulfills the necessary conditions for the exchange. These conditions are based on issuing a similar transaction with ETH coins. If something goes wrong with any transaction, the initial transaction has a certain security measure that will allow the user to recover his coins through the OP_CODE.
If both transactions are issued we reach the point where both users have issued a transaction, but no one has the payment. This is the point where the conditions are checked to effectively unlock the money and perform the exchange. Both users must reveal the code of the transactions and will be able to use them to unlock the script that holds the payments.
If one of the two users has acted maliciously, the other user can employ the security measures implicit in the transactions. These measures are time locks whose function is to ensure that transaction funds remain inaccessible to both parties involved for a certain period of time. When this time has elapsed, if one of the two parties still does not comply with the agreed conditions, the other party can withdraw its money from the exchange and everything will be as it was at the beginning.
Cross-chain swaps on all cryptocurrencies?
Although we have seen an example with Bitcoin and Ethereum, it does not mean that the rest of cryptocurrencies cannot perform cross-chain swaps, in fact, cryptocurrencies such as Monero are developing protocols that allow adding these functionalities.
All cryptocurrencies have the ability to cross-chain swaps as long as they meet two requirements. These are to allow blocking at the script level and to allow blocking at the time level.
As we have seen in the previous example, both blockchains are used to add greater security to transactions achieving much safer exchanges. The only limitation present in this system is the one that developers can establish by not supporting certain functions and equivalences in the blockchain and in the cryptocurrency itself.
Advantages and disadvantages of Cross-chain Swaps
Like all mechanisms, cross-chain swaps have their own advantages and disadvantages that differentiate them from other mechanisms. Below we will see the most important ones:
Among the advantages of using cross-chain swaps are:
- Enable new decentralized functionality. In addition, they allow a much more secure and private functionality to perform cryptocurrency exchanges without relying on centralized or decentralized exchanges.
- It generates a greater dynamic of cryptocurrency use. This system allows us to increase the use of coins. This is due to the fact that the exchange of cryptocurrencies offers us the possibility of increasing our use of coins at any time and in a totally easy and safe way. Let’s imagine that we have to exchange our BTC for DASH, since a certain establishment only accepts the second cryptocurrency. With this mechanism we could achieve this in a matter of minutes.
Among the disadvantages that can be found in this system are:
- Risk of losing our money. If we trust wallets that have a poor implementation of this kind of protocols we run the risk of losing our money. This is due to the fact that the security of this system is mainly based on the programming of precise and secure conditions that offer us protection at all times.
- Complexity. Cross-chain swaps can be somewhat complex to manage, especially for users who are just starting out in the world of cryptocurrencies.
As an alternative to cross-chain swaps, there is another exchange system known as Succint Atomic Swaps. The operation of this system also allows cryptocurrencies to be exchanged between different blockchains. It is only seen as an alternative, as it is a system that is still in practice, but it could be the beginning of a great replacement.