In order to understand how cross-chain bridges work and how cross-chain swaps are performed, it is worth comparing the trading mechanisms on centralized (CEX) and decentralized exchanges (DEX). Why you can easily change coins on CEX without thinking about what blockchains they work on, but it’s not so easy to exchange BNB to ETH on DEX.
Table of Contents
How crypto exchanges work
So, the user wants to exchange one cryptocurrency for another, that is, to sell coin A and buy coin B. On a centralized exchange, these assets are stored on exchange wallets, hot or cold, but each of the coins quietly “lies” on its blockchain. The exchange has its own registry, which records that n coins A have been deducted from the user’s balance and m coins B have been credited.
The assets themselves do not move on their actual blockchains, and therefore the blockchain commissions are not debited from the user’s balance. This is convenient and fast, but still not very secure:
First of all, the exchange can be hacked and part of the funds stolen. Almost all top CEX have been hacked at least once during their existence.
The exchange may turn out to be a fraudulent project or it may be blocked for some reason. As a result, you will not be able to withdraw your coins.
At CEX, you need to pass KYC and the requirements are gradually tightening. For some, it is fundamentally important to remain incognito.
DEXs are free from these risks. Of course, they also have their own problems, but of a different nature. Such platforms operate on blockchains that support smart contracts and only tokens from the same blockchain can be exchanged for them.
- Suppose we have blockchain A (let’s say Ethereum). All tokens within the blockchain are interconnected and can be traded on Uniswap, Pancakeswap and other DEX on Ethereum. Coins and tokens from other blockchains are not displayed. The transaction requires gas, which is paid in ETH.
- Another blockchain B works similarly (for example, Solana). Only payment for gas will be charged in SOL.
However, blockchains A and B are incompatible with each other and it is impossible to exchange tokens from different blockchains without additional steps.
Cross-chain bridges and cross-chain swaps
Cross-chain swap is the exchange of assets that are in different networks using bridges. Let’s take a closer look at how this happens.
In fact, the token is blocked on the original blockchain, and a copy of it is created on the other blockchain. These copies are backed by locked tokens.
For example, we need to transfer USDT from the Ethereum blockchain to the Binance Smart Chain network. The tokens are locked in an Ethereum smart contract and as soon as this happens, the smart contract sends a signal to the bridge. A bridge is a separate piece of software that checks if assets are blocked and sends a signal to another blockchain. This signal activates a smart contract on another blockchain and it creates an exact copy of the locked assets and they can be used.
Risks of cross-chain bridges
Bridges are vulnerable to hacks and, for obvious reasons, are a very attractive target for hackers. If the attack on the bridge is successful, the assets will be stolen and their copies will lose their value.
There are several types of bridges:
- Fully autonomous bridge. The developers wrote the program, posted it on the network and no longer have access to it. This is a very unfortunate option, since blockchains are constantly updated, and the bridge becomes obsolete and at some point will lose compatibility with blockchains.
- centralized bridge. That is, a certain organization says that it has created a bridge, and assets can now be transferred using its services. However, in this case, there is a non-zero probability of running into scammers.
- Bridge type DAO. Several people have access to such bridges. By common agreement, they use the ability to access smart contracts, implement updates, etc.
An important caveat: you should not keep assets in a bridged state for a long time. It is better to exchange them for other network tokens, otherwise there is a risk of losing funds due to a hacker attack.