Blockchain across Oracle
上QQ阅读APP看书,第一时间看更新

The underlying mechanism

In technical terms, one of the mechanisms that is commonly used by sidechains is called a two-way peg. This mechanism lets you transfer assets to and from sidechains and, in the process, transform vanilla assets into all other flavors that you can imagine.

Let's look at doing this using the example of cryptocurrencies, where a two-way peg lets us transact Altcoins, such as Litecoin, at a fixed rate. This means that you can take two Bitcoins from the parent or main chain and purchase two Litecoins on the sidechain at a 1:1 fixed rate. Those Litecoins can be sent to someone on that sidechain, and then he or she can redeem them at the same 1:1 rate on the parent chain and receive back two Bitcoins.

This works as follows, and is shown in the following diagram. When a parent chain transfers some assets to sidechain assets, it uses a two-way peg by utilizing a simple payment verification (SPV) technique. The parent chain sends the asset to a special SPV-locked output (1) on the parent chain. These assets can only be unlocked when an SPV proof of possession (2) is performed by the sidechain. While the assets are locked in the main chain, they can be freely transacted (3) in the sidechain without losing the identity of the parent chain. However, they can only be transferred back to the same parent chain from which the assets came and not to another parent chain. If you want to exchange the assets back from the sidechain to the parent chain, you need to follow the same process. The assets are transferred to an SPV-locked output (4), and they need to produce a sufficient SPV proof of possession (5, 6) to unlock the previously locked output on the parent chain:

Example of a two-way peg transaction that allows you to transfer assets between different blockchains

It is in the best interest of both the parent chain and the sidechains that sidechains only transfer the same kind of assets, and that different assets are not interchangeable. A different asset should be treated as a malicious transfer because it can be worthless. We will not focus on the use of sidechains in this book, but keep in mind that they exist and can be useful if you want to develop a different implementation based on existing assets.