Your first smart contract

Before we go any further, let's be concrete and jump into our first smart contract right away. The following code shows what a standard Hello World smart contract, written in a higher programming language (Solidity), looks like:

pragma solidity ^0.4.24;

contract HelloWorld {
string message = "hello world";

function setMessage(string msg_) public {
message = msg_;
}

function getMessage() public view returns (string) {
return message;
}
}

If you're a developer, this code should be understandable; there is nothing complex. We define a variable, message, with two functions, a setter and a getter. What differs is the fact that we are dealing with a contract that easily stores a given message in Ethereum's blockchain, without using an I/O stream or database connection. We will take a closer look at the meaning of each element later in this chapter. You can copy , paste, and compile this code by using an online IDE, such as Remix (remix.ethereum.org). You will find further details on handling Remix in the next section.

Voila! You have created your first Hello World smart contract.