What is Smart Contract

A smart contract is a computer program or a transaction protocol that is intended to automatically execute, control or document events and actions according to the terms of a contract or an agreement. The objectives of smart contracts are the reduction of need for trusted intermediators, arbitration costs, and fraud losses, as well as the reduction of malicious and accidental exceptions.

Similar to a transfer of value on a blockchain, deployment of a smart contract on a blockchain occurs by sending a transaction from a wallet for the blockchain. The transaction includes the compiled code for the smart contract as well as a special receiver address. That transaction must then be included in a block that is added to the blockchain, at which point the smart contract's code will execute to establish the initial state of the smart contract. Byzantine fault-tolerant algorithms secure the smart contract in a decentralized way from attempts to tamper with it. Once a smart contract is deployed, it cannot be updated. Smart contracts on a blockchain can store arbitrary state and execute arbitrary computations. End clients interact with a smart contract through transactions. Such transactions with a smart contract can invoke other smart contracts. These transactions might result in changing the state and sending coins from one smart contract to another or from one account to another.

The most popular blockchain for running smart contracts is Ethereum. On Ethereum, smart contracts are typically written in a Turing-complete programming language called Solidity and compiled into low-level bytecode to be executed by the Ethereum Virtual Machine. Due to the halting problem and other security problems, Turing-completeness is considered to be a risk and is deliberately avoided by languages like Vyper. Some of the other smart contract programming languages missing Turing-completeness are Simplicity, Scilla, Ivy and Bitcoin Script. However, measurements in 2020 using regular expressions showed that only 35.3% of 53,757 Ethereum smart contracts at that time included recursions and loops — constructs connected to the halting problem.

Notable examples of blockchain platforms supporting smart contracts include Ethereum, Bitcoin, Binance Smart Chain, Solana, Avalanche, Tron, Polygon, Ton, and Ethereum layer 2 network - Arbitrum, Optimism, Base etc. To learn more about differences between Layer 1 and Layer 2, please visit -> https://www.mulana-im.com/blog/what-is-layer1-vs-layer2.