What exactly is a Smart Contract????

Abhi Kerni
3 min readDec 21, 2018

Smart Contract is made of two words i.e. “Smart” and “Contract”. Let us first start with “Contract”,after that we will make it “Smart” ;)

“Contract” in Smart Contract simply means a piece of code with various methods or function which will behave in a particular way every time.Think of this as some simple java class ex. Math.java but Smart Contracts are written in different languages.

Some random Smart Contract Code taken from internet….

In block chain terms class Math.java is kind of a contract and one of its method i.e. random() is a part of contract and will behave always same i.e it will return random value every time when called. Suddenly it will not start returning something else except a random value.

So in short any code is actually a contract with specified or documented functionality. String.length() function is a contract and its contract says that it will return length of String.

Now what makes our contract or code “Smart”??????????

“Let me make your code smart”

“Smart” has two part :

  1. Immutability
  2. Only intended person can call particular functionality.

What is immutability?

Lets lock your code here forever..

Above class Math.java is not immutable(now this immutable is not java immutable of final keyword).Immutable means once it is deployed in an environment it stays there forever and no one can change it forever and forever means no downtime and till eternity unless all computers shut down at once or some meteor strikes earth. Math.java is not immutable because its functionality can be changed by java developers in next version.

So next question which platform provides us immutability functionality??

  • Block Chain

Code once deployed on block chain lets say on Ethereum Blockchain will stay there forever without getting altered by anyone and without any downtime. Block Chain provides us these two things i.e no downtime and immutability.

No Down Time No alteration….

Second part of “Smart” is that only intended person can call particular functionality. How do we achieve this????

By using secure calls or private/public key concept.Suppose we have below method deployed on block chain.

oneOfMethodOfContractDeployedOnBlockChain()
{ if(method Call signed by key "7hjde3dfgdeds2ww3ji2982")
triggerFunctionality();
else
return error;
}

Only person that can trigger functionality of above method is someone who owns private key of public key “7hjde3dfgdeds2ww3ji2982”, no one else can trigger it, since the above code is on block chain no one can change it as well.

So in short Smart Contract is basically..

Code + immutability + Only Authorized User Can trigger functionality or change its state(forget about state change for now..)

--

--