Blockchain and Smart Contracts for Naive Developers

The word “Naive” in the title is not exactly address the audience of this posts. It does not mean “dummy” or “silly” but rather “old-fashioned”, “learned old things”, “used to live in pre-blockchain world” but still “smart” and “educated”.

So, for this kind of developers the word “blockchain” may be explained as “cloud, free (almost), immutable, very slow on adding new records database”. That’s all. No cryptos, currencies, big moneys and all that. Just slow immutable database. And immutability is the key. If you do not need immutability you do not need blockchain — use of any other database would be much better.

The “crypto currency” was just a first and natural application of the blockchain database. In fact: the nature of money is to be never revoked of forgotten. Every transfer of a coin from a person to the other must be confirmed either piece of metal or the records in the bank database. This exactly the records in the blockchain database called “Bitcoin” means: “an entity 0x4580ffff … received NNN units of equity from an entity 0x93432fdf… “. Call that units “bitcoins” and nominate the equity in goods or real money and the “crypto currency” is born.

Now the people all around are looking for the profitable application of the blockchain mutability and those attempts is the reason of all the hype around.

The next step of the blockchain is “smart contracts”. While the blockchain is a “database of records” the smart contracts is a “collection of object instances”. The difference of the objects from the records in the scientific terms is “objects have state and behaviour” or, the same in the more familiar words: “object have fields AND methods”.

The very same is about smart contracts with the immutability added: as soon as an object instance is put into the blockchain its state may not be change in the other way as a result of the internal life cycle programmed by the smart contract developer or by calling the public methods.

Thus as soon a developer put an object (“smart contract”) called “Deal #0x343454354…” on the Ethereum blockchain it will stay in “non closed” state forever till the the public method “close” will have been called. Since that the state of smart contract will be ultimately “closed” with no way to change it. This a way to use the blockchain for signing the agreement or contracts.

The last and probably most interesting part about the smart contracts is they can be receiver of crypto currency (this is not exactly that is going on, but the most clear understanding) and their methods may send that currency to the recipients. Here the real magic starts. If the algorithm of smart contract can detect some event in the outer world it can initiate transfer the money automatically and nobody can interrupt the process.

The obvious sample is Escrow systems used to trade internet domain names. It is trivial to check if the domain transferred to the designated person, so the amount hold by the contract can be released to the seller. If the transfer would not happen in the predefined time the amount returns to the buyer. Very natural.

In the most cases though the human intervention still is necessary but the process of the money transfer become as easy as “an insurance company agent confirmed the car is damage with hit iPhone app and the driver receives the compensation in next 10 minutes or so”.

That’s all. Nothing really complex or magical. The old good things: databases, records, objects. Just immutable.