What is a smart contract?

Smart contracts are actually programs that runs on blockchain. Let’s understand this so what first comes into your mind when you hear the word “contract”? Probably a set of rules right, yeah you are right a contract is a set of rules on which two or more parties agree to govern the relationship between them.

And what are programs? programs are basically languages which we use to interact with computers, in programming we also define rules like this for that and so on like we do in a contract. Smart contracts are basically codes that runs on blockchain they interact with blockchains, if blockchain is a car than smart contracts are basically like drivers which drives them and tells them what to do.

Bitcoin Vs Ethereum

Etherum-Versus-Bitcoin
Bitcoin Vs Ethereum

Let’s understand through a example for example see Bitcoin, In bitcoin there is a programming language called bitcoin script, which actually allows you to code things on the bitcoin blockchain.

And the same time in Ethereum there is a programming language called solidity which of course allows you to code on its blockchain. The major difference between bitcoin script and solidity is that solidity is turing complete while bitcoin script is not. Turing completeness means that if a programming language is turing complete that means that you can code any logic into that language.

So, now the question is that why bitcoin script is not turing complete? Well, that is because bitcoin script language lacks an important component called loops. and it is intentional the reason why they did not make it turing complete is because as blocks of bitcoin runs on every single node in the chain they can really slow the chain down, and if somebody intentionally creates a program that has an infinite number of loops this program can destroy the whole blockchain, that’s why they kept bitcoin script non-turing complete.

Now you may have a question that if that’s the reason than how solidity is able to provide loops features? Well, Solidity has found a way to include loops that is Ethereum has concept of gas, which means ether tokens it works like suppose you want to code on Ethereum blockchain using solidity than everytime you need to make a calculation you need to pay gas aka ether tokens now if someone wants to destroy Ethereum blockchain by coding an infinite loop they can not as they will need to pay for completion of every loop and since money is not infinite they will eventually run out of ether tokens to perform further completion of loops. This way Ethereum is affording turing completeness of solidity.

Leave a Reply

Your email address will not be published.