Let’s say you want to cook some authentic italian spaghetti. First off, this intro might be too complicated, but you’ll learn how I make spaghetti. This is what you wouldn’t do… throw in some spaghetti noodles, sauce, and hamburger meat all in a pan and wait for it to boil. That would just be some bad soup.
Instead, you cook the noodles in a big pot and brown the hamburger meat in another pan, instead of using one big pan. This way when the time is ready, you can strain the water out of the noodles and then add in the cooked meat. In a sense, you outsourced the meat cooking to another pan, instead of trying to cook the meat in the same pot that the noodles were boiling. You’ll see how this relates to sidechains in a second.
What are sidechains?
Sidechains are a separate blockchain that is connected to another blockchain through a two-way peg to help process some of the data from the main blockchain.
Before we move on too much, let’s go over a review of what a layer 2 scaling solution is and why we need them. Basically, main blockchains are really slow. If we try to speed them up, they aren’t as secure or safe, so we have to find a secondary method to make them faster. These solutions are called layer 2 scaling solutions and we have a video where we briefly go over a bunch of popular ones, but this video is about a specific one called sidechains.
Sidechains attempt to take some of the work that a main blockchain needs to do, and do it for them. How do they do this? Most sidechains are a little more centralized than the main chain, but this is okay, because we will trade off security for speed, just… we don’t want to do it on the main chain. This may be our first important point of sidechains: they are responsible for their own security.
Another point is that sidechains need their own validators or miners. They can even have their own consensus mechanisms, meaning they can pick if they want proof of stake, proof of work, or something as crazy as proof of space and time. Validators and Miners usually earn rewards for their work in a sidechain in the same manner that all other blockchains work.
One cool things about sidechains is that many of them allow merge mining. This is a term that means you can mine or validate two blockchains at once, earning double the rewards, with roughly the same amount of work. The technicals of how this works are outside the scope of this video, but leave a comment below if you want us to explain it in a future video - don’t forget to subscribe either!
The next big point is to explain the two way peg. They call it a two way peg because they are pegged moving onto the sidechain and pegged moving back onto the main chain. We call these two processes Locking up and Releasing.
Locking Up Funds
So when you move your coins and tokens from the main chain to the sidechain, you have to lock them up, otherwise you’d have free tokens on both chains. Locking them up usually means they go to a wallet or contract controlled by a machine or code, not a human… and that you have to do something special to get them back.
Nevertheless, when you lock up your coins on the main chain, you get your new coins and tokens on the sidechain. They are basically the same thing, but this allows us to move things back and forth without allowing people to duplicate their coins.
When you locked up your coins and tokens on the main chain, the protocol accepted them and actually mints you new coins and tokens on the sidechain so that you have representations of them on the sidechain. Then when you want to switch back, you destroy your coins and tokens on the sidechain and you get to release your funds on the main chain.
Back to our crazy spaghetti analogy earlier, if you did all the transactions and data on the main chain, it would get super congested and backed up, similarly if you cooked the spaghetti, water it was boiling in, meat and sauce all in one pan. Instead, we split it up until multiple pans that have different purposes. In the case of a sidechain, it is meant to be a bit more centralized but allow many more transactions so the network can scale. When users are ready to move back to the main chain, they just have to move their funds through the locking and releasing mechanism and hope the federation lets them.
A federation is the technical term for the middle man that is in charge of locking and releasing those tokens and assets between the two chains. Not all sidechains need a federation, but many of them do because they are useful. Some federations are completely code, while many are controlled by the sidechain’s organization.
The federation is in charge of making sure whatever is locked up, is exactly what’s on the Sidechain, so that the sidechain never has more value and tokens in it than those that are locked up. In fact, many people say Federations are a huge risk of centralization between moving funds back and forth between a main chain and a side chain.
Rootstock, or RSK as it is commonly called, is simply a sidechain to bitcoin. Bitcoin doesn’t really have the ability to do smart contracts, mostly just process transactions. However, Rootstock is a sidechain that allows the usage of smart contracts. Rootstock’s Federation is made up of 25 of the biggest blockchain exchanges out there, and the have created this bitcoin bridge where you can transfer your real bitcoin for Rootstock versions of bitcoins so you can do smart contract stuff with it. RSK is pretty much ethereum but for bitcoin - you can run smart contracts, you use gas, and even the development programming is similar.
Polygon or the Matic Network is roughly a sidechain for Ethereum. Ethereum has been crazy backed up in the past few months, meaning high transaction fees. Polygon, formerly Matic, is a sidechain to Ethereum that allows you to perform almost the same interactions, although at tenths to hundredths, even up to a thousand times cheaper. The block time on Polygon is also 2 seconds compared to Ethereum’s 10 seconds. Using the Matic bridge, you can move assets from Ethereum to Polygon in less than an hour at any time you want to. Polygon is one of the most well known sidechains due to it’s mass adoption and ability to interact with Ethereum. We have a whole video on Polygon coming up, so get ready to watch that video.
One thing to keep in mind with sidechains is that they are permanent solutions that are difficult to greatly change once they are in place. Rollups and Channels are two other layer 2 scaling solutions that are not as permanent but can be changed quicker and easier. Faster iterations means faster feedback, which means faster overall development.
Finishing Up & Quiz
Anyways, we have covered almost everything there is to know about the general idea of a sidechain in the crypto world.