Getting Started with Rootstock Development
Learn about Rootstock, how it enables smart contract on Bitcoin, and its compatibility with Ethereum and other platforms.
What is Rootstock?
Rootstock is Bitcoin's financial infrastructure. It is an open-source, EVM-compatible Bitcoin sidechain secured by over 85% of Bitcoin's hash power through merge mining. Businesses, financial institutions, and builders use it to launch Bitcoin-secured lending, payments, yield, and treasury products with Ethereum tooling.
The full technology stack runs on that Bitcoin-secured base: from smart contracts on the Rootstock Virtual Machine to services in the Rootstock Infrastructure Framework (RIF). See The Stack.
Rootstock connects to Bitcoin through merged mining and through a shared unit of account. BTC locks in the PowPeg and issues rBTC 1:1 on Rootstock. Rootstock is also compatible with Ethereum at the virtual machine and JSON-RPC layers, so Solidity tooling and familiar wallets work with little change.
Let's briefly look at each of these areas.
PowPeg
The second point of contact is the PowPeg. This component connects both networks to allow the transfer of bitcoins to Rootstock, thereby allowing developers to interact with smart contracts. They pay gas using rBTC, which is pegged 1:1 with BTC.
To do so, you send bitcoin to a special address, where they are locked in the bitcoin network. Next, in the same address over in the Rootstock network, that same bitcoin is released to the user for use in the Rootstock 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 Rootstock network, and receiving your bitcoin back in the bitcoin network.
Differences with Rootstock and Ethereum
Rootstock is not 100% compatible with Ethereum: It has differences in the way checksums are calculated, the derivation path it uses, and how gas is calculated.
Checksum differences
- Different Ethereum-compatible networks differentiate themselves using “chain IDs”.
- Each blockchain network has its own unique chain ID.
- Rootstock uses the chain ID when calculating checksums for its addresses, whereas Ethereum does not take this into account.
- Checksums in both networks are represented using capitalisation (uppercase and lowercase letters), so the “same” address will not pass checksum validations on both Rootstock and Ethereum.
Derivation path differences
Remembering or storing private keys for your crypto wallets can be super challenging, even for technical people. This is because these keys are essentially extremely large numbers. So to make things easier, the crypto community has come up with a technique called “HD wallets”, where using a seed phrase (a set of randomly chosen dictionary words), plus a “derivation path”. Rootstock and Ethereum have different derivation paths, therefore, the same seed phrase results in a different set of keys and addresses between Rootstock and Ethereum.
Gas differences
The EVM and RVM are compatible in that they support the same op-codes, and therefore can run the same smart contracts. However, the price of each op-code (measured in units known as gas) is different between EVM and RVM, thus the total gas consumed in various transactions is different. Further to that, gas units are multiplied by gas price to calculate the transaction cost. Since Rootstock’s gas price is denominated in rBTC and Ethereum’s gas price is denominated in Ether, there is another difference between gas prices on Rootstock and Ethereum.
We have identified that the opcodes with significant variations are SLOAD and SSTORE.
Additionally, certain calls (such as DELEGATECALL and STATICCALL) that utilize these opcodes during an internal call will result in differences in the overall gas cost calculation for the transaction.
These discrepancies are primarily due to EIP-2929 that has been implemented in Ethereum but not yet in Rootstock. The team is aware of this difference and intend to implement this in future releases.