Like many terms in the blockchain industry, smart contracts are likewise confusing and not easily understood. While a legal contract outlines the terms of relationships enforced by law, a smart contract enforces a relationship with cryptographic code.
The idea of Smart Contracts described by computer Scientist and cryptographer John Szabo is as a digital vending machine in which users can input data and value and hence obtain meaningful information. Take, For example, Ethereum users can send 12 ether to a friend on a certain date using a smart contract. In this case, the user creates a contract and then pushes the data to that contract so that it could execute the command.
How Smart Contracts Work
Ethereum allows developers to program their own smart contract which supports a broad set of computational instructions.
Smart contracts can:
- manage user agreement, say, if one user buys insurance from another user.
- provide utility to other contracts
- store Information about an application, such as domain information, etc.
- regulate funds spending by functioning as a multi-signature account
Finally, smart contracts are sometimes in need of assistance from other contracts. For example, if I place a bet on a certain football team to win another, one contract would use outside information to determine the winner, and another contract would settle the bet placed on the information it received from the first contract when all the conditions are met.
Ethereum smart contracts are Turing-complete, what means that theoretically any kind of information processing could be done with smart contracts. It is possible to write say Tetris program in the form of a smart contract (however, it would run slow and expensively and require an unusual user interface).
Running smart contracts requires transaction fees, which depends on the amount of computational power required. Ethereum runs a smart contract code when a user sends its information to another user with enough transaction fees. Smart contracts are then executed by Ethereum Virtual machine in ‘byte code’, a form of binary code which is however distinct of the binary code of the CPU which actually runs the computer.