Blockchains - Smart Contracts - Part 1
Index of all Chipkin blockchain articles : BLOCKCHAIN AND THE INTERNET OF THINGS Index
By: Peter Chipkin
Article Contents
- Smart Contracts are part of the Blockchain
- What is a Smart Contract
- A Simple Example – A lottery
- How are Smart Contract Programmed?
- What does a Contract Look Like
- Contracts and Legal Contracts
Smart Contracts are part of the Blockchain
Four elements characterize Blockchain
Replicated ledger
History of all transactions — Append-only with immutable past — Distributed and replicatedConsensus
Decentralized protocol — Shared control tolerating disruption — Transactions validated
Cryptography
Integrity of ledger — Authenticity of transactions — Privacy of transactions — Identity of participants
Business logic
Logic embedded in the ledger — Executed together with transactions — From simple "coins" to self-enforcing "smart contracts"
What is a Smart Contract
A fancy name for a program or app that is embedded in the block chain.
Its useful to look at the differences between a regular computer app and a smart contract. A smart contract has visible source code and source code that cannot be changed after the fact so that once verified, you know exactly how it will operate. Your know how it will operate today, tomorrow and the next day because like all data in the block chain it is visible and immutable.
Most regular apps don't have this degree of transparency so its impossible to verify the app output with certainty.
Not all blockchains have been designed to allow source code and applications to be embedded in them. Bitcoin does not allow smart contracts. Ethereum does. It was designed for it. The designers of the blockchains make choices about what programming language(s) they provide to implement these smart contract apps.
In the context of blockchains and cryptocurrencies, smart contracts are:
- pre-written logic (computer code)
- stored and replicated on a distributed storage platform (eg a blockchain)
- executed/run by a network of computers: (usually the same ones running the blockchain)
- and can result in ledger updates (cryptocurrency payments, etc)
… In other words, they are little programs that execute "if this happens then do that", run and verified by many computers to ensure trustworthiness.