Writing your first bitcoin smart contract

To write smart contracts in RSK, we should use Solidity, which is an Ethereum smart contract language. In this chapter, we will not go into detail about Solidity, but rather we will limit the explanation to how to deploy and interact with a Solidity smart contract in RSK. 

As a first smart contract, we consider the following code snippet:

pragma solidity ^0.4.21;contract store {    string public Message;    function set (string NewMessage) public {        Message = NewMessage;    }}

If you're unfamiliar with Solidity, know that this smart contract defines a variable called Message and a setter method to edit its value. In other words, we read and store a message into the blockchain.

Get Blockchain By Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.