Leveraging the power of Bitcoins with RSK

Learn how RSK works and how to deploy your smart contracts to it

I'm always interested in what other ways one can use their blockchain and Solidity skills. While many projects are still only in the planning or in testnet status, with Rootstock (RSK) you can transfer mainnet Bitcoins to an EVM sidechain and vice-versa already today. Utilizing the power of the EVM allows you to deploy Solidity contracts and use existing Ethereum infrastructure and tooling around it.

Let's see how to use it...


What is RSK?

RSK is a sidechain for the Bitcoin blockchain with full EVM support. This means you can deploy Solidity contracts here, while leverage the security of Bitcoin mining. Most tools will also have support for the RSK chain given its EVM capability.

All details can be seen in the Whitepaper.

What is the RSK sidechain?

Sidechains generally are EVM-compatible, separate blockchains with their own consensus models. Sidechains are designed to easily allow transfer of value and arbitrary state with the main chain. RSK is special as it's not connecting towards the Ethereum mainnet, but rather the Bitcoin blockchain.

+ allow you to run fully functioning smart contracts
+ value exchange with Bitcoin main chain

- security currently still relies on a set of 15 trusted notaries

How is the sidechain secured?

The sidechain of RSK is run by Bitcoin miners via 'merged mining'. Any Bitcoin miner can choose to additionally become a miner in the RSK network without having to allocate extra resources for the RSK chain. How does that work?

  1. The miner creates a block for the RSK chain containing all newly added transactions in the RSK chain.
  2. The miner then hashes this block and creates a valid Bitcoin transaction containing the hash and adds it into the existing new Bitcoin transactions.
  3. Now the miner creates the final Bitcoin header with this transaction in it.

Now there are three scenarios:

  1. The new block satisfies the Bitcoin difficulty which will be the least likely. In this case the RSK block hash is simply ignored, but the overhead is tiny as it's just a single additional hash. The transaction fees from the Bitcoin network will go towards the miner.
  2. The new block satisfies the RSK difficulty, but not the Bitcoin difficulty. In this case only the RSK block will be activated and integrated in the RSK sidechain. The transaction fees from the RSK network will go towards the miner.
  3. The new block doesn't satisfy any difficulty, so it's just ignored.

As you can see, almost no extra work is required for the miner this way. The difficult part of computing hashes has to be done only once for the Bitcoin and RSK chain at the same time. This incentivizes Bitcoin miners to also mine RSK as it's simply free additional money. As of now the participation rate is very high ranging from 60% to 80%. The higher the more secure the sidechain will be.

How is the transfer between Bitcoin and RSK secured?

The current 2-way peg design in RSK allows to transfer Bitcoins from the Bitcoin blockchain to the RSK chain and vice-versa.

Current Design: Transfers are secured by 15 public and well-known, trusted notaries. Once you lock Bitcoins in the main chain, they will control those funds. Only once you burn the funds in the RSK chain, will the notaries return your funds on the main chain.

The obvious advantage here is that the system is not fully decentralized.

Notary Bridge

Future Design: In the future RSK may change the design to a so-called drive-chain. In this design the locked funds are solely controlled by the Bitcoin miners. Unlocking funds happens in a voting period. For this to work however, a new OPCODE in Bitcoin would be required and thus a soft fork introducing the new capability. An existing proposal for a BIP (the Bitcoin equivalent of EIP) is here.

Hybrid: This future design could be added in a hybrid model depending on miner participation. If the miner participation is low, keep the current design with notaries. But as participation increases, give more and more power to the miners. Eventually only miners will control the funds.

You can find more details about the two peg design here.

Dynamic Hybrid RSK
Hybrid RSK

RSK further told me they are about to announce their PowPeg very soon, a new peg system. This will come in the form of a blog post and an accompanying page on our developer portal.... so watch this space!

Existing projects on RSK

But not only that, many projects or forks of those already exist inside RSK. Some highlights include:

Uniswap Fork Another One

How to deploy to RSK

Deploying to the RSK sidechain is very simple. If you're using Truffle, simply add the network configuration like this:

Truffle's built in HDWalletProvider, as well as the bundled Web3Provider, were previously using hard coded values that are OK for Ethereum, but not OK for RSK. This was due to larger block times, the resulting rate limits configured on our public nodes.

You can now override these defaults - to make Truffle work better with RSK.

testnet: {
      provider: () => new HDWalletProvider({
        mnemonic: {
          phrase: testnetSeedPhrase,
        providerOrUrl: 'https://public-node.testnet.rsk.co/2.0.1/',
        // Higher polling interval to check for blocks less frequently
        pollingInterval: 15e3,
      // Ref: http://developers.rsk.co/rsk/architecture/account-based/#chainid
      network_id: 31,
      gasPrice: Math.floor(gasPriceTestnet * TESTNET_GAS_MULT),
      networkCheckTimeout: 1e6,
      timeoutBlocks: 100,
      // Higher polling interval to check for blocks less frequently
      // during deployment
      deploymentPollingInterval: 15e3,

Without the above, you're likely to run into intermittent failures for truffle migrate, and intermittent warnings when you leave truffle console running.

You'll also need funds in the sidechain of course. For the testnet, just use the available faucet here. For mainnet you need to use the bridge as described below and further use the config:

  • provider: () => new HDWalletProvider(mnemonic, 'https://public-node.rsk.co')
  • network_id: 30

Be aware that for production services you may not want to rely on a public node, but rather run your own RSK node.

Onboarding users


To interact with the side chain, users need to add the RSK network to their MetaMask. Click on the network selection in MetaMask and then choose 'Custom RPC'. For the current testnet, use the configuration of

  • RPC URL: https://public-node.testnet.rsk.co
  • ChainID: 31
  • Symbol: tR-BTC
  • Block Explorer URL: https://explorer.testnet.rsk.co

For mainnet you can use

  • RPC URL: https://public-node.rsk.co
  • ChainID: 30
  • Symbol: R-BTC
  • Block Explorer URL: https://explorer.rsk.co
RSK MetaMask

Value transfer from and to RSK

1. Getting the native RSK (BTC <-> R-BTC)

To get the native RSK token, you only need to transfer Bitcoins to the bridge address.

  1. To have a testnet BTC address, start Electrum in testnet mode.
  2. If you want to try it in the testnet, obtain some testnet BTC via https://testnet-faucet.mempool.co/.
  3. Now using MyCrypto, choose the RSK Testnet in “More Networks” and navigate to “MyCrypto -> Contracts -> Select Existing Contracts -> “Bridge” -> “getFederationAddress”. This will give you the bridge address for the testnet. You can send BTC to this bridge. 
  4. Your respective RSK EVM key can be generated from the Bitcoin address using the converter tool.

The way back is even easier, just send the (t)R-BTC to the address 0x0000000000000000000000000000000001000006. Done.

2. Moving Ethereum ERC-20 tokens to RSK (e.g. DAI <-> r-DAI)

RSK Token Bridge

Since RSK is an EVM compatible chain, it makes sense that they further offer to transfer Ethereum tokens to it. To move a token between RSK chain and Ethereum mainnet, there is a bridging system that is very easy to use. You can use the following services:

  1. For the mainnet use https://tokenbridge.rsk.co/.
  2. For the testnet (BTC testnet <-> Kovan testnet) use https://testnet.tokenbridge.rsk.co/.

Future RSK Development

The obvious next step for RSK would be integrating the described drivechain design. However since it's relying on a Bitcoin soft fork, we have no idea when or even if this is will be coming in the future. If you have further details about it, I'd love to hear it and please leave a comment.

Otherwise the team is working on bring meta-transactions to the system:


The Research & Innovation team is developing a solution for meta-transactions named Enveloping. The main goal is to allow users to submit transactions to the network through a service provider (Sponsor) and pay for this service in tokens, removing the need to get native currency to operate with our blockchain network.

Horacio S. Caceres (Qubistry)

Have you used RSK before? Maybe even on Mainnet? Let me know in the comments.

Next week we will look at everything one needs to know about ERC-1155, so stay tuned!

Markus Waas

Solidity Developer

More great blog posts from Markus Waas

  • Zeppelin

    Openzeppelin Contracts v4 in Review

    Taking a look at the new Openzeppelin v4 Release

    The Openzeppelin v4 contracts are now available in Beta and most notably come with Solidity 0.8 support. For older compiler versions, you'll need to stick with the older contract versions. The beta tag means there still might be small breaking changes coming for the final v4 version, but you can...

  • Loan

    EIP-3156: Creating a standard for Flash Loans

    A new standard for flash loans unifying the interface + wrappers for existing ecosystems

    As we've discussed last week, flash loans are a commonly used pattern for hacks. But what exactly are they and how are they implemented in the contracts? As of right now each protocol has its own way of implementing flash loans. With EIP-3156 we will get a standardized interface. The standard was...

  • Zero

    Tornado.cash: A story of anonymity and zk-SNARKs

    What is Tornado.cash, how to use it and the future

    With the recent Yearn vault v1 hack from just a few days ago, we can see a new pattern of hacks emerging: Get anonymous ETH via tornado.cash . Use the ETH to pay for the hack transaction(s). Use a flash loan to decrease capital requirements. Create some imbalances given the large capital and...