Smart Contract is an immutable executable code representing a logic of a Dapp. They contain the state and operations that enforce the verification, validation and recording rules on the blockchain. Smart Contract is a brain of a Dapp.
Dapps are web or enterprise applications that involve logic to invoke blockchain functions that implement trust intermediation.
Applications are hosted on nodes.
A smart contract is a bit like a class in OOP. It should have clear rules and data.
A contract consists of:
- a name
- rules/modifiers for invoking functions
- functions that may change the state and generate transactions
Rules are not necessary. Rules/modifiers are a bit similar to encapsulation in OOP. They are gatekeepers that control access to data and functions. They allow the specification of rules of validation and verification. They are meant for realizing trust.
Once deployed onto the blockchain, a smart contract is immutable. Therefore, before deployment, smart contracts should be tested thoroughly.