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.
Sidechains are secondary blockchains that are connected to a main blockchain, allowing for assets and data to be securely transferred between them. They provide a way to test new features or handle specific tasks without overloading the main blockchain, much like having a smaller, specialized road linked to a major highway for specific types of traffic.
So, just like you wouldn’t put all the pasta contents in one pot, sidechains make it so you don’t have to put all the data of a blockchain on the main chain, otherwise it just gets messy.
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. One specific solution is 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. We just don’t want to make that trade 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 on a sidechain in the same manner that all other blockchains work.
How Sidechains 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 article, but leave a comment below if you want us to explain it in a future article!
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, similar to 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 sidechain.
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.
The Polygon Network is roughly a sidechain for Ethereum. Ethereum has been crazy backed up when it gets busy, 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.
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.
Anyways, we have covered almost everything there is to know about the general idea of a sidechain in the crypto world. They are one solution to speed and transaction costs on primary blockchains.
Thanks for reading, hope you enjoyed it, and we really hope you learned something!