Smart Contract Guide


What is a Smart Contract?

Smart contract is a computer protocol designed to digitally verify, facilitate and enforce negotiation of a contract onto a blockchain. Contracts can be converted to computer codes, replicated and supervised on the network of computers that run the blockchain. Examples and use cases are healthcare, insurance or transport services etc.


Smart Contract Process

Caption: Process of a Smart Contract.

 

Why is Smart Contract needed?

Anything that works on a decentralized blockchain should be immutable and capable of operating through numerous nodes without compromising on its integrity. Hence, a smart contract for a decentralized blockchain needs to have the following characteristics:

1. Terminable.

2. Deterministic

3. Isolated.


1. Terminable

A smart contract needs to be able to be terminated, aborted or be externally “killed” when its execution exceeds a time limit. This is to ensure the contract will not drain resources needlessly by entering into an endless loop.


2. Deterministic

A program that always provides the same output from a given input is called deterministic. There are times when a program becomes un-deterministic:

  Data for a program is acquired from a data source that is un-deterministic.

  When a programmer calls an un-deterministic system functions in their program.

  When a program executes dynamic calling, meaning calling a second program. The program is un-deterministic because the call target can only be determined after the execution completes.


3. Isolated

Everyone can upload a smart contract to a blockchain which may cause serious problems to the entire system because uploaded contracts may contain virus or bugs. It is hence important for a contract to be isolated and stored in a sandbox to prevent it from impacting the ecosystem in a harmful way.


Smart contracts usually run on the following systems.

 Virtual Machines

 Dockers


Virtual machines provide smart contracts with an environment that is more superior in terms of terminable, deterministic and isolation capabilities, while dockers provide coding language flexibility. Developers using a virtual machine such as Ethereum, have to learn a whole new language (solidity) to develop smart contracts.


Advantages of Smart Contracts

Smart Contract transactions on a developed Blockchain are secure, trackable, fast, irreversible and allow the performance of credible transactions without going through third parties. Smart contract security is superior to traditional contract law and is capable of reducing transaction costs associated with contracting and cryptocurrencies. Ethereum and EOS are well known open-source, blockchain based distributed computing platforms designed primarily for smart contracts.


NEXT: 12. Read the Guide to Decentralized Applications.