An intro to Bitcoin layer 2

One of the first comments Satoshi Nakamoto got when publishing his Bitcoin whitepaper was that ‘it does not seem to scale to the required size’.

Years later, it has shown that it scales and fulfills its purpose as a store of value. It just hasn’t scaled in the area of a medium of exchange, if you compare it to fiat. The transaction fees are quite high and take a minimum of 10 minutes to settle. Terrible if you’d want to buy a coffee with your bitcoins.

Why are transaction fees so high and why does it take so awfully long? It’s not a bug, it’s a feature. Block time and block size influences a lot of what is going on here.

Why does it take so long? The block time is a constant (around 10 minutes) in the system to ensure miners can’t just add more compute power to validate a block faster (details here).

Let’s look at fees; Transactions on the network need to be settled and are thus batched into blocks. Miners compete to validate the transactions in the block and earn a block reward, paid out in bitcoin. The basic fee we users pay for a transaction relates to the size of the transaction in bytes.

With block time at 10 minutes, a block is created every 10 minutes. If your transaction can’t make it onto the block, you’ll have to wait for the next block or buy priority, paying a higher fee on top of the basic fee.

 

Why do we need a 2nd layer?

So why don’t we just increase the block size to fit more transactions into a block? Well if the blocks are smaller then it requires less compute power to run a node and verify the blocks. Less compute power means, everyone can run a node and confirm transactions without special computers. If decentralisation is the ultimate goal of a crypto currency then this is among the most important aspects.

> A node is a participant in the network and can verify blocks and thus verify if transactions are legitimate.

You see, Bitcoin is kind of perfect the way it is and that’s why the community so far has opposed requests to change any of these parameters.

How we can still have our cake and eat it.

This is where the 2nd layer comes into play. Layer 1 is the base layer, the foundation, Bitcoin, Ethereum and others. Layer 2 is all the fancy stuff built on top that is decoupled from the main blockchain either off chain or on a sidechain.

Compare this to real world money; it exists in the form of notes or electronically as a ledger at our bank and can be used to purchase stuff via transfer or handing over paper. Paypal is something built on top. You can use it to securely pay online, but you need to wire in funds from your bank account.

Credit cards might also be a good example as you can use them conveniently to pay even the smallest amounts by tapping, but once the bill is due, you need to pay using your bank account and the receiving end will also get their money onto a bank account once the transaction is settled.

 

So how can we use Bitcoin to pay for a coffee?

The Bitcoin community has been working on what is called the Lightning Network. It is a peer to peer network on top of Bitcoin that reduces transaction fees and settles payments very quickly.

How? I like to think of it as a portal. You send some Bitcoin into a trusted wallet and a portal to layer 2 opens, on layer 2 you now have the equivalent amount in sats (a more granular version of bitcoin) to pay for a coffee, shop groceries or just wire some coins to a friend. Once you’re done, the portal closes and the remaining balances get settled into your bitcoin wallet. While you use your sats on the lightning network there is no interaction with the Bitcoin network.

The trick is that all these portals — or channels as they are really called — can be connected via lightning nodes to create a network. When opening a channel (think of the portal) you initially intend to open it to one other wallet i.e. peer to peer to the coffee shop. Once a channel is opened, however, it can be connected to other channels, meaning you won’t need to open a new channel for every transaction.

The network allows you to route your payments into other channels, connecting you to other wallets on the network. Put simply, you wire bitcoin into the wallet, pay sats for coffee or groceries and what is left can be settled back into your bitcoin wallet or kept on the network for later purchases. The coffee shop and grocery store will receive their bitcoin into their bitcoin wallet when requested. Kind of like a prepaid card.

A good, free book on the Lightning Network can be found here (open source on GitHub).

 

Will it gain adoption

It depends. The current way of using a credit / debit card / smartphone with NFC to tap for a payment is pretty convenient. However, most add a surcharge to pass the cost and small businesses might not accept credit cards at all due to fees and necessary infrastructure (card reader). Equipped with just a smartphone a small business could allow lightning network payments and save on fees.

Someone on the internet has a done a nice comparison of fees:

source: https://medium.com/@geniepaylightning/visa-paypal-bitcoin-or-lightning-network-lets-compare-270263b54cb1

Everything else will be based on network effects. The more people using and accepting it, the faster the adoption. So far here in Sydney I haven’t been able to buy a coffee with it.

After becoming a real medium of exchange, what’s next?

Paying for a coffee is just one thing that’s hard to do with bitcoin. What about a whole financial system like defi? What if we could have a layer 2 to lend, borrow, swap, trade and mine liquidity? These are decentralised applications (dapps) we know mostly from the Ethereum ecosystem and while Ethereum has really picked up speed, Bitcoin seems in its infancy when it comes to defi.

Ethereum is built so it can run applications in a smart contract — a piece of coding that reacts to inputs from the blockchain. Bitcoin does not really have this feature as it opens the network for potential attacks. Developers of the Bitcoin ecosystem have watched Ethereum’s rise and started to develop Bitcoins answer to smart contracts on layer 2 as a sidechain.

> a sidechain is a separate blockchain connected to the main blockchain to run additional functionality not available on the main chain.

 

Let’s have a look at how RSK adds smart contracts to Bitcoin.

RSK runs it’s sidechain on top of Bitcoin using merge mining. Bitcoin miners can use their hashpower to secure the RSK sidechain without any additional effort on their side — in fact they get paid a block reward from RSK on top of what they earn from Bitcoin since they don’t have to stop mining bitcoin. So they have their own blockchain, but don’t need a token since the chain is secured by Bitcoin miners running merge mining.

RSK describes how their sidechain works as follows:

> You send bitcoin to a special address, where they are locked in the bitcoin network. Next, in the same address over in the RSK network, that same bitcoin is released to the user for use in the RSK network. This is called peg-in.

> You can do the reverse operation called peg-out, by sending your bitcoin to a special address in the RSK network, and receiving your bitcoin back in the bitcoin network.

The native currency RBTC (which is just mapped to BTC) is then used to pay for processing of smart contracts similar to how you use ether to pay for smart contract execution on Ethereum.

This again brings to life dapps like Sovryn, built on RSK, enabling lending, borrowing, swapping, trading and liquidity mining just as you know it from defi on Ethereum but using native bitcoin and a Layer 2 Bitcoin solution.

So what advantage does Bitcoin defi have over Ethereum defi? Ethereum had a massive head start and a big ecosystem when it comes to defi. Bitcoin on the other hand has a much higher market cap and with that a bigger adoption and is known by a lot more people.

I don’t think it makes sense to compare them at the end both – and other – ecosystems deliver features to users. Generally, the more defi the better, the more we shift to decentralised applications, the more we move away from our broken legacy financial system.