Transferring tokens between peg zones

Last week I was telling someone about Cosmos and tried to explain how users can transfer tokens between the interconnected zones in the network. While explaining, I got stuck. I then realized that my understanding of how tokens can be transferred between zones was coming short. After doing research on how transfers within the Cosmos network actually work, I decided to write this post summarizing all the information and share it with the community. In doing so, I ended up making the infographic below. 

Let’s first take a look at the critical parts of the Cosmos network. The network is going to mainly consist out of hubs and zones. These hubs and zones will be setup according to the Hub & Spoke architecture (see illustration below)(Source: A beginners guide to Ethermint). At first there will only be one hub, the CosmosHub.

In order for the hub and zones to be really connected with each other, they need to be able to communicate. Therefore they should use a language that all the zones and hub(s) speak and understand. This is where the IBC protocol comes into play. IBC stands for Inter-Blockchain Communication. Since zones can now communicate via IBC, they can send information back and forth securely. The hub also plays a crucial role in this part, because it keeps track of how many tokens are being held in each zone.

Sending the tokens

So lets see how everything comes together when we send 1 BTC to an Ethereum address via the Cosmos network. First of all, we need to send the 1BTC to the Bitcoin peg zone. Once transferred to the peg zone, the bitcoin is being locked and a Bitcoin peg native token is being created. For this example we call it CosmosBTC. Now that we have 1CosmosBTC, we need to somehow trade it for CosmosEthereum in order to get Ethereum. 

To be able to trade the CosmosBTC for CosmosEthereum we need to move it to a zone that allows trading. For this specific purpose there will be so called DEX zones. Within these zones there could be countless ways of trading your CosmosBTC for CosmosEthereum. There are already projects like OmiseGo and 0x, that are working on becoming a DEX solution for the Cosmos Network.

Now we know to what zone we need to send the CosmosBTC to, we initiate the transfer. First we send the CosmosBTC to the DEX zone. The CosmosBTC is being locked in the Bitcoin peg zone and a proof is being sent to the DEX zone via the hub. Once the proof arrived at the DEX zone it will lookup the validators set of the BTC peg zone. Once it has proof that 2/3 of the validators confirmed that the specific CosmosBTC is locked, it will create the CosmosBTC in the DEX zone.

With the CosmosBTC on the DEX zone we can trade it with someone that has CosmosEthereum and wants our CosmosBTC. After we successfully traded/swapped our 1CosmosBTC for x amount of CosmosEthereum we can send it to the Ethereum peg zone. The same process with locking and checking the validator set will take place. Now we have CosmosEthereum on the Cosmos peg zone and can send the CosmosEthereum to a real Ethereum address. The conversion of CosmosEthereum to real Ethereum will go via a smart contract.

We have successfully swapped our BTC for Ethereum via the Cosmos network! To make this process visually better understandable, the above posted infographic was made. I hope this helps clear things up on how this process works. If you have any questions let me know.

Sources: