INITIALLY, I THOUGHT THAT ETHEREUM WAS A THING THAT WOULD BE USED FOR PEOPLE TO WRITE SIMPLE FINANCIAL SCRIPTS. AS IT TURNS OUT, PEOPLE ARE WRITING STUFF LIKEĀ AUGURĀ ON TOP OF IT. -VITALIK BUTERIN
In last years, with the increasing of Blockchain-based technologies and with the born of always new cryptocurrencies, the concept of Smart Contract started to sound louder and louder. Letās try to briefly explain what they are and why they are becoming increasingly important and used in in the most varied contexts.
AĀ Smart Contract is just a program, written in a particular programming language (eitherĀ Turing-completeĀ or not) that runs as programmed, without being able to be censured or manipulated, where the code is law and with the aim to facilitate operations between people and institutions.
We can find Smart Contracts in many environments.

Examples of Smart Contract on different platforms.
For example,Ā Bitcoin utilizes Script, a Forth-like reverse-polish notation stack-based, processed from left to right, very simple programming language. A Smart Contract in Script is just a list ofĀ Opcodes instructionsĀ recorded with each transaction. However, although Bitcoin Smart Contracts are functional to the objectives set, they are not widely used in many scenarios. One reason could be the fact that Script is not Turing-complete, avoiding the possibility of using loops or cycles.
Currently, theĀ most known Smart Contracts are those of Ethereum, which are also the main focus of this brief discussion. They can be written in several programming languages such asĀ Solidity, Serpent and LLL. Solidity, the most popular among these, is a high-level language, influenced by C++, Python and JavaScript. It is designed to target the Ethereum Virtual Machine, the Ethereum byte-code execution environment that every node runs to be able to send and receive transactions.
A Solidity Smart Contract looks like this
pragma solidity ^0.4.21;
contract Coin {
// āpublicā rende le variabili
// accessibili dallāesterno
addressĀ publicĀ minter;
mappingĀ (addressĀ =>Ā uint)Ā publicĀ balances;
// Gli eventi permettono ai client di
// visualizzare i cambianti nella Blockchain
// Ā in maniera efficiente
eventĀ Sent(addressĀ from,Ā addressĀ to,Ā uintĀ amount);
// Costruttore che viene eseguito
// solamente quando il contratto viene creato
function Coin() public {
minter = msg.sender;
}
functionĀ mint(address receiver, uint amount)Ā publicĀ {
// msg.sender ĆØ lāindirizzo di colui che fa la transazione
ifĀ (msg.senderĀ !=Ā minter)Ā return;
balancesĀ +=Ā amount;
}
functionĀ send(addressĀ receiver,Ā uintĀ amount)Ā publicĀ {
ifĀ (balancesĀ <Ā amount)Ā return;
balancesĀ -=Ā amount;
balancesĀ +=Ā amount;
emit Sent(msg.sender, receiver, amount);
}
}
As one can see,Ā Solidity is also a contract-oriented programming language, meaning that there exist keywords dedicated to who makes transactions, to sent and received ether and much more. We donāt go deeper in further technical details about the syntax. A complete guide can be foundĀ here.
With a Smart ContractĀ one can program many type of scenarios, from aĀ simple storage of data, to theĀ triggering of certain operationĀ after receiving money, fromĀ decentralized applicationĀ (Dapps) toĀ decentralized games.

CryptoKitties is one of the worldās first games to be built on blockchain technology.
As all the transactions in Blockchain, alsoĀ Smart Contracts are permanently stored without any possibility of modifications. This means thatĀ once done the deploy of the contract on the chain, it cannot be altered. For this reason, security in Smart Contract is of fundamental importance. In fact, just think that ether can be managed by them and so, even just a small error in the logic of programming, can result in large economic losses. A āfamousā example is about the drama ofĀ DAO, where wrong implementations of a part of the code led to millions of dollars/ether losses.
Developing Smart Contracts is not an easy task. To help with it, thereĀ exist some best practices, that allow a programmer to know how not to set up a contract preventing serious points of failures. Also, as support tools there exist many software, such as Truffle in case of Ethereum, that allow to safety code in a local environment to better test in all possible ways Smart Contracts before the final deploy.
Smart Contracts can be a very powerful tool able both to create value, security and efficiency, but also to being used to create chaos from even simple errors. For this reason, one should be particularly careful in coding them and deploying in the main network, if they manage sensitive data or money.