The term Smart Contract have been a matter of research for over the years. It was until the advent of blockchain technology since it started gaining some momentum.
Note: Although many blockchains such as Hyperledger, Nem, Polkadot support smart contracts, in this article, we'll be talking about ethereum as it is currently the most popular blockchain among smart contract developers.
The term smart contract was first coined in 1994 by Hungarian cryptographer Nick Szabo. He defined it as -
A set of promises, specified in digital form, including protocols within which the parties perform on the other promises.
In the context of blockchains, a smart contract is simply a program that runs on the blockchain. It resides at a specific address on the blockchain network. You can think of it as a set of agreements between a buyer and a seller, written in the form of code. It helps to perform safe transactions in a trustless environment.
Smart Contracts are similar to an Externally owned user account (EOA). They have an address, balance and they can send or receive transactions like user accounts too. However, unlike EOA, smart contracts cannot be controlled by any user. As a creator of a smart contract, you don't get any privilege on the protocol level. Although you can code functions that only the owner of the contract can use e.g. moving all the contract's balance or a self destruct operation.
Properties of Smart contracts
The terms and conditions written in the smart contracts are accessible by everyone. Its execution is the same for all the users using the contract.
Once the contract is deployed on the blockchain, its code cannot be edited. The only way to modify it is to redeploy a new instance.
Smart contracts use cryptography and permissions to ensure the data and ether balance collected is safe. However, they are also vulnerable to bugs in the code that may make the contract unsafe for use.
For a given transaction and a given state of the blockchain, the output of transaction execution will always be the same.
The transactions performed by smart contracts are governed through logic code and executed by computers. This makes smart contracts capable of performing transactions at a very high speed.