Skip to Content

👨🏻‍🎓 Register for live classes

Smart contracts intro

Smart contracts can be considered a type of computer program, with some different characteristics that will be presented here. But, first of all, let's understand its origin.

History

The term smart contract was coined around 1993, by Nick Szabo, a brilliant man with multiple backgrounds: computer science, cryptography and advocacy.

Inspired by his articles, we can say that the "vending machine", that automatic machine that sells soft drinks and snacks, was the ancestor of the smart contract, because we can choose a product, pay and withdraw our product in an automated way, without human intervention.

Likewise, a smart contract is a tool for structuring rules and agreements in programming codes, ideally registered in an environment where there is no possibility of changing the program. But this did not exist in the 90s, Nick Szabo idealized something that only came true with Blockchain!

Smart contracts in Ethereum

The first Blockchain that started its network in January 2009, the Bitcoin, defined by Satoshi Nakamoto, was not prepared for the implementation of smart contracts.

Enter Vitalik Buterin, who realized that a Blockchain could go far beyond cryptocurrency transfers, then creating Ethereum.

Vitalik saw Blockchain as a decentralized global computer, an environment where smart contracts could be executed.

Are smart contracts... contracts ?

Thinking in the legal sense of contracts, smart contracts are NOT contracts!

You can say that they implement legal contracts, but all clauses, rules, obligations, benefits or penalties have been previously defined.

Are smart contracts... smart ?

Smart brings us to the concept of artificial intelligence and learning from data analysis.

Smart contracts are NOT smart!

They perform exactly what has been defined, they are immutable and your code cannot be changed.

What is smart contracts?

Smart contracts are computer programs published and executed in a Blockchain environment, capable of being carried out or enforced on their own, without intermediaries.

A smart contract can obtain information, process it and act in accordance with the rules of the contract, autonomously, but it needs an external agent to start its execution. For example, it is scheduled in a smart contract that it will send a certain amount on the next year. By yourself, it has no way of knowing whether the date has passed. Someone or another external system must execute the smart contract so that it can verify if it is time to make the transfer.

When we think about the immutability of Blockchain, another important point about a smart contract is that, once published, it is not possible to correct the code! However, the smart contract may have been programmed with functions to change data. The information can be recorded in one block, deleted in another, but the history remains, and it is possible to audit.

Solidity programing language

Solidity is an object-oriented, high-level language for implementing smart contracts. Smart contracts are programs which govern the behaviour of accounts within the Ethereum state.

It is a curly-bracket language, which means that the characters { and } defines statement blocks.

Solidity is influenced by C++, Python and JavaScript, and is designed to target the Ethereum Virtual Machine (EVM).

It is statically typed, supports inheritance, libraries and complex user-defined types among other features.

From Solidity docs

RSK

The RSK network uses the same smart contracts as Ethereum, that is, they are also written in Solidity.

RSK's virtual machine implementation is compatible with the Ethereum EVM, so we can also use many of Ethereum's developer tools.

Final considerations

The purpose of this lesson was to present an introduction to smart contracts and why we also use the Solidity language at RSK. In module 3 you will learn more about the RSK network.

For now, what we present is enough for you to create your first smart contract.

In the next lesson you will learn about Remix, a very easy to use development environment.