How Smart Contracts Work
Smart contracts, also known as a smart properties and chaincode, are agreements that have been codified inside a blockchain. Smart contracts are code — simple “if-then” and “if-then-else” statements. They’re created with code that is built inside a blockchain. Ethernet and Hyperledger Fabric are popular blockchains for creating smart contracts.
The blockchains records data on their smart contracts and have a history of the smart contracts’ balance of cryptocurrency and a history of all their transactions.
Smart contracts have an internal memory containing their code. The code gets executed when predetermined restrictions are met. These restrictions could be internal or external to the smart contract.
If the code for the smart contract needs an external source to determine if it has met its restrictions, it will use an oracle (a source of knowledge). An oracle could be a data feed for weather, for example. This would be useful if the smart contract were executing an insurance contract for crops. Following this example, the contract would look something like this: “If the temperature drops below 32 degrees for more than one hour, release $5,000 to John.”
The smart contracts facilitate, verifies, and enforce the performance of a contract. There is no outside part or legal system that interprets the contract and the intent of the parties. The code is law.