RSK Smart Contracts - A Simple Guide to Get Started

Updated on: July 22nd, 2020
This content has been Fact-Checked.
RSK Smart Contracts

One of the unique opportunities given by the RSK network is the ability to code smart contracts on Bitcoin’s blockchain. As such, developers will be able to leverage the flexibility of smart contracts and layer them on to the security provided by Bitcoin‘s blockchain. In this guide, we will see how smart contract coding works and how we can deploy them on RSK.

Smart Contracts in Blockchain

Smart contracts are one of the most interesting use cases of blockchain technology. When Bitcoin first came out, everyone thought that the blockchain was nothing more than a vehicle for decentralized financial fulfillment. However, things change pretty drastically with the advent of smart contracts, which made it possible for developers to customize the blockchain as per their needs. Smart contracts are automated contracts. They are self-executing with specific instructions written on its code, which get executed when certain conditions are made.

Introduction to Solidity

For anyone who wants to learn how to make dAPPs (Decentralized Applications), learning Solidity is an absolute must. Solidity was developed by Gavin Wood, Christian Reitwiessner, Alex Beregszaszi, Yoichi Hirai, and several former Ethereum core contributors to enable writing smart contracts on blockchain platforms such as Ethereum.


Solidity is meant to be a purposefully slimmed down, loosely-typed language with a syntax very similar to JavaScript. You can check out the Solidity Docs right here.


By using solidity, you will be coding smart contracts that are going to be executed in the ethereum Virtual Machine, aka EVM. Ethereum developers mention a set amount of gas that is assigned to their contracts. Each line of the contract requires some amount of gas to execute. The gas limit should be enough for the contract to execute entirely.


Data Types in Solidity


Firstly, let’s cover the data types that you will be using in solidity. In computer science and computer programming, a data type or simply type is a classification of data that tells the compiler or interpreter how the programmer intends to use it.


Is the data an integer or a string or an array?


The way the compiler makes these decisions is by looking at the data type.


So, firstly, let’s check the integer data types that you will have in solidity:

  • Normal integer declaration called “int” which goes from -128 to 127
  • Unsigned Integer “uint” which goes from 0-255 and doesn’t store any negative values


Up next, we have boolean data types which only stores “true” or “false”. To declare boolean values you do this: bool a;


After that you have Strings and Bytes.


You can use string in solidity as this: string name. Strings are stored as an array of values in solidity.


Bytes is an array of bytes which goes from 1-32 characters. So what is the difference between Strings and Bytes?


Solidity documentation says:


“As a rule of thumb, use bytes for arbitrary-length raw byte data and string for arbitrary-length string (UTF-8) data. If you can limit the length to a certain number of bytes, always use one of bytes1 to bytes32 because they are much cheaper.”


Up next, we have a cool data type called “enum,” which allows users to define their own data type.


enum Action {REMOVE, UPDATE}


So, how do you use them in the program?


Action myAction = Action.UPDATE;


In the snippet above, you created a variable of the type Action, which has “remove” and “update” functionalities.


You can read the solidity docs to get a more in-depth knowledge on various data types.


Deploying smart contracts on RSK

While there are several methods that you can use to deploy your contracts on RSK, the smart contract platform on top of Bitcoin, we will look into the standardized methods as described by the official RSK blog.


#1 Setting up your environment


You can use several tools to set up your environment, and it mostly depends on your OS or the platform you are most comfortable with. Some examples of these are:

RSK Smart Contracts

#2 Tools


RSK has a testnet and a mainnet. You can create our own node and connect it to either the testnet or the mainnet. Depending on your OS, you can install your node the following way:


  • Linux:
  • MacOS:
  • Windows:
  • Microsoft Azure Marketplace:
  • Amazon Web Services Marketplace:


In order to interact and see the network status, here you can find the links:

RSK Smart Contracts

The RSK testnet provides developers with the following tools:


  • A faucet that provides developers with “R-BTC” coins to run their smart contracts.
  • A testnet wherein the developers can freely create and test out their smart contracts.


Alright, now that you have a fair idea about what you’ll need to set up your environment and the various tools you’ll require to code smart contracts. If you want a detailed breakdown of how the whole process works, click here.

Why Bitcoin needs smart contracts and RSK

If the future is going to be decentralized, smart contracts will be at the heart and soul of this revolution. As we have mentioned before, smart contracts can make the underlying blockchain programmable. This is why large-scale organizations like Deloitte have started researching the ins and outs of smart contracts.

We have already seen numerous use cases of smart contracts. However, the impact that it can have on Bitcoin is truly immense. Pre-RSK, Bitcoin was known only as a simple payment protocol. However, RSK and smart contracts can bring unprecedented utility to the Bitcoin blockchain. By building a healthy and thriving ecosystem on top of the blockchain, Bitcoin will move on from a purely speculative currency to a viable financial solution.

Having said that, Bitcoin is known to be notoriously slow, managing only 7-10 transactions per second. As we have already seen with Ethereum and cryptokitties, smart contract platforms are not going to be efficient if they aren’t scalable. However, this is another place where RSK can immensely help Bitcoin.


  • Firstly, we have Lumino. Lumino Network allows parties to transact off-chain using payment channels. While it functions similarly to the Lightning Network (LN), they have both been designed to work side-by-side with each other. Lightning Network works on the main chain, while Lumino works on the RSK sidechain. 
  • Finally, the RSK protocol itself runs on a side chain. This means that it can divert all the complex smart contract calculations away from the main blockchain, reducing bloat.

Where does RSK stand in the smart contract landscape?

  • Let’s state the obvious first. Ethereum is the leader of the smart contract space. We also have other projects like EOS, Tron, and Cardano that have shown a lot of promise. However, the advantage that RSK has over all other projects is the Bitcoin blockchain’s security and credibility.
  • On top of that, RSK also has token bridges that connect directly to the Ethereum blockchain. Not only does this allow the contract creator to leverage the advantages of both the blockchains, but it also allows for the creation of a thriving, interoperable ecosystem between the two.


Conclusion –  RSK Smart Contracts

The beauty of creating RSK contracts as a developer is that you can leverage the best of both worlds – the programmability of Ethereum and the security of Bitcoin’s blockchain. For further information, we invite you to check RSK’s smart contract development guides.

Rajarshi Mitra
Rajarshi started writing in the blockchain space after listening to Andreas Antonopoulos’ podcast with Joe Rogan. A content generating machine, Rajarshi has been consistently producing high-quality guides and articles for us since late 2016. His articles have been shared extensively in social media and several start-ups have used his guide as learning material for their staff. He is continuously invited all over his country to give talks in various crypto seminars and conferences. He has gained a solid reputation as a speaker/educator on top of being one of the most promising writers in the crypto space. When he is not busy nerding out over the latest in the blockchain/crypto space, he is usually busy watching re-runs of top gear and MMA.

Like what you read? Give us one like or share it to your friends and get +16

Hungry for knowledge?
New guides and courses each week
Looking to invest?
Market data, analysis, and reports
Just curious?
A community of blockchain experts to help

Get started today

Already have an account? Sign In