What is a smart contract?
Smart contracts are similar to normal contracts in the real-world but have a number of differences. Two or more parties agree on a set of terms, and when these terms are met, the smart contract executes in an execution environment. . What makes smart contracts different from normal contracts is the automation of the execution, the transparency of the terms, the ownership and control of the contract, and the certainty that what is written in the contract will surely be executed. The contracts are a set of instructions, in code, that are deployed on a blockchain. These instructions represent an agreement between parties that are presented as an executable computer program. The computer program is executed by a blockchain-based platform that enables the deployment of smart contracts. The execution only takes place when predetermined conditions are met.
The EVM is the first example of this, which checks the validity of the input and checks the conditions of the smart contract to execute the contract.
How does a smart contract work?
The execution of a smart contract is a transaction. The more complex a smart contract is, the more computational intensive the execution will be, thus, more gas is needed. After smart contract execution, the end result is broadcasted to the network, so the network maintainers can introduce the transaction in a new block and the EVM changes the state of the blockchain after the new block is introduced in the blockchain. Therefore, the result of the smart contract will always remain written in the history of the blockchain and is visible to anyone.
Properties of a smart contract
Immutability is one of the main properties of smart contracts. Once the content of the smart contract has been agreed upon by the parties involved and deployed to the EVM, it can no longer be changed, and will automatically be executed when the specified requirements are met.
Smart contracts are also incredibly flexible and can be more than a financial instrument, used to move funds at a known future date for example. There are a variety of use cases for smart contracts in the fields of economics, finance, medicine, and law to name a few.