smart contracts - github pages · smart contracts on top of smart contract blockchains (e.g....
TRANSCRIPT
![Page 1: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/1.jpg)
Smart ContractsRaymond Cheng
Dawn Song
Slides credits: Andrew Miller & Ari Juels
![Page 2: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/2.jpg)
• Currently #2 public cryptocurrency• Many of the top cryptocurrencies are implemented as
smart contracts on top of smart contract blockchains(e.g. Ethereum)
![Page 3: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/3.jpg)
Ethereum may overtake Bitcoin in market cap
Source: coinmarketca
p
![Page 4: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/4.jpg)
![Page 5: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/5.jpg)
What do we expect from contracts?
• Language to specify terms of the agreement• A way to specify your identity and consent• Enforcement and dispute resolution
![Page 6: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/6.jpg)
What is a smart contract?
• User-defined programs running on top of a blockchain• Smart contract simulates trusted third party with shared state.
Contracts
Code
Storage
Data
Users Money Decentralized Consensus (“Blockchain”)
![Page 7: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/7.jpg)
“Smart contracts”conceptualized by Szabo in 1994A smart contract is a computerized transaction protocol that executes the terms of a contract. The general objectives are to satisfy common contractual conditions (such as payment terms, liens, confidentiality, and even enforcement), minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries. Related economic goals include lowering fraud loss, arbitrations and enforcement costs, and other transaction costs.
-Nick Szabo “The Idea of Smart Contracts”
For example: Smart contract reassigns physical access to your car from you to your bank if you don’t make a payment
![Page 8: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/8.jpg)
$20,000 10 sharesGOOGL
GOOGL⇑ = $2000by 30 Sept 2019
Suppose Alice and Bob strike a deal…
Problem of Fair Exchange!
![Page 9: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/9.jpg)
Smartcontract
$20,00010 shares GOOGL
$20,00010 sharesGOOGL
GOOGL = $2000By 30 Sept. 2019
Virtual trusted third-party (with public state)
![Page 10: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/10.jpg)
Virtual trusted third-party (with public state)
$20,00010 shares GOOGL
$20,00010 sharesGOOGL
GOOGL = $2000By 30 Sept. 2019
![Page 11: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/11.jpg)
Okay great, we want smart contracts, but why on blockchain?
![Page 12: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/12.jpg)
Cryptocurrency Exchanges
Mt. Gox$10,000 1 BTC
$10,0001 BTC
BTC = $10000By 30 Sept. 2019
![Page 13: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/13.jpg)
Okay great, we want smart contracts, but why on blockchain?
![Page 14: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/14.jpg)
#1: Smart contracts must enforce correct execution
![Page 15: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/15.jpg)
Smart Contract Applications
• Tokens• Lotteries• Insurance• Supply-chain management• Marketplaces• Cryptocurrency exchanges• “Self-sovereign” identity management• Covenants• Sharing economy• And many more!
![Page 16: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/16.jpg)
Token Smart Contracts
Init: balance[creator] = 1,000,000
Transfer($amt, from, to): Assert balance[from] ≥ $amtbalance[from] := balance[from] - $amtbalance[to] := balance[to] + $amt
Contract stores everyone’s balance
Transfer moves tokens fromone account to another
![Page 17: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/17.jpg)
#2: Transactions to smart contracts must beall-or-nothing
![Page 18: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/18.jpg)
Lottery Smart Contract
Init: Tend := 7 June 2018, $ticket := 1 , pool := {}, pot := 0
TicketPurchase($amt, P): On receive $amt from party P:Assert $amt = $ticket, balance[P] ≥ $amtbalance[P] := balance[P] - $ticketpot := pot + $ticketpool := pool ⋃ P
Timer:If T > Tend thenW ∈R poolbalance[W] := balance[W] + pot
Contract stores the end time,ticket cost, current pool, and pot
If the party has enough money, add them to the pool and their money to
the pot
At the end, select a winner
![Page 19: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/19.jpg)
#3: Contracts are enforced by the blockchain
![Page 20: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/20.jpg)
FlightInsurance
Gimme a $100 policy
(Flight #1215, 17 May, Policy price: $1)
$100
Automated Insurance Contracts
$1
![Page 21: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/21.jpg)
#4: Contracts have an auditable history
![Page 22: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/22.jpg)
Smart contract properties
• Guaranteed to execute correctly• Malicious miner cannot cheat
• Transactions are all-or-nothing• Autonomous: Enforced by network• Cannot be changed or stopped, even by its creator
• All data is stored on the blockchain• Auditable history
• Intuition: Smart contract simulates trusted third party with public state.
![Page 23: Smart Contracts - GitHub Pages · smart contracts on top of smart contract blockchains (e.g. Ethereum) Ethereum may overtake Bitcoin in market cap Source: coinmarketca p. What do](https://reader030.vdocuments.mx/reader030/viewer/2022041103/5f02c9637e708231d4060160/html5/thumbnails/23.jpg)
Traditional contracts vs. smart contracts
Traditional Smart
Specification Natural language + “legalese”
Code
Identity & consent Signatures Digital signatures
Dispute resolution Judges, arbitrators Decentralized platform
Nullification By judges ????
Payment As specified built-in
Escrow Trusted third party built-in