Smart Contracts September 23, 2019 guha.jayachandran@sjsu.edu - - PowerPoint PPT Presentation

smart contracts
SMART_READER_LITE
LIVE PREVIEW

Smart Contracts September 23, 2019 guha.jayachandran@sjsu.edu - - PowerPoint PPT Presentation

Smart Contracts September 23, 2019 guha.jayachandran@sjsu.edu Whats a Contract? Whats a Contract? A legally binding agreement which recognizes and governs the rights and duties of the parties to the agreement Pacta sunt servanda


slide-1
SLIDE 1

Smart Contracts

September 23, 2019

guha.jayachandran@sjsu.edu

slide-2
SLIDE 2

What’s a Contract?

slide-3
SLIDE 3

What’s a Contract?

“A legally binding agreement which recognizes and governs the rights and duties of the parties to the agreement”

slide-4
SLIDE 4

Pacta sunt servanda

slide-5
SLIDE 5

What’s a Contract?

If this, then that

slide-6
SLIDE 6

Smart Contract

If this, then that

slide-7
SLIDE 7

Smart Contract

First proposed by Nick Szabo in 1994

slide-8
SLIDE 8

Smart Contract

Self-executing contract Computerized transaction protocols that execute terms of a contract

slide-9
SLIDE 9

How Does it Work?

slide-10
SLIDE 10

How Does it Work?

Everyone evaluate contract, consensus reached on outcome

slide-11
SLIDE 11

How Does it Work?

Bitcoin - Bitcoin script Ethereum - EVM Some cryptocurrencies support, some don’t

slide-12
SLIDE 12

Examples

Transfer value if signed Transfer if multi-signature provided “Tipping point” funding Provable casino Prediction markets …

slide-13
SLIDE 13

Ethereum Smart Contracts

Turing complete Write in high-level language and compile to EVM bytecode Solidity

slide-14
SLIDE 14

Sample Solidity

Source: solidity.readthedocs.io

slide-15
SLIDE 15

Digression: UTXO vs. Account-Based

  • UTXO = Unspent transaction output
  • Graph of transactions like in Bitcoin from before.
  • Your money is spread across your (potentially) many

UTXOs

  • Account-based
  • There is a specific account associated with your key on

the blockchain

  • When you spend or receive, your account is updated
slide-16
SLIDE 16

Sample Solidity

Source: solidity.readthedocs.io

slide-17
SLIDE 17

Questions

How do you prevent DOS? Everyone runs the contract? Bugs?

slide-18
SLIDE 18

Gas

Transaction creator charged gas_price * gas If you run out of gas, transaction does not complete

slide-19
SLIDE 19

Dapp

Decentralized application

slide-20
SLIDE 20

DAO

Decentralized Autonomous Organization

slide-21
SLIDE 21

The DAO

2016 Investor-directed venture capital fund No human directors/managers Cross-border Raised $150 million in crowdsale Legality?

slide-22
SLIDE 22

The DAO

Bug resulted in $50 million hack What would you do?

slide-23
SLIDE 23

Code = Law ?

slide-24
SLIDE 24

Is the right thing to do to respect the transparent smart contract or the human intentions?

slide-25
SLIDE 25

The DAO

Outcome: Fork of Ethereum into Ethereum (restore hacked funds) and Ethereum Classic (go along with hack)

slide-26
SLIDE 26

Flaws Continued

Many hundreds of millions of dollars in smart contract hacks Prompting efforts in formal verification

slide-27
SLIDE 27

Real-World Interaction

  • But how would you know if the seller actually delivered possession?