introduction to blockchain - lecture 3: from bitcoin to ...bitcoin blockchain: a revision a...

43
Introduction to Blockchain Lecture 3: From Bitcoin to Ethereum Ras Dwivedi Indian Institute of Technology Kanpur May 22, 2018 Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 1 / 32

Upload: others

Post on 29-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Introduction to BlockchainLecture 3: From Bitcoin to Ethereum

Ras Dwivedi

Indian Institute of Technology Kanpur

May 22, 2018

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 1 / 32

Page 2: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Outline

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 2 / 32

Page 3: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Bitcoin Blockchain: A Revision

A Decentralized Ledger

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 3 / 32

Page 4: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Transactions

Figure: CaptionRas Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 4 / 32

Page 5: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Block

NonceHash of last block

Transaction 1

Transaction 2

Transaction 3

Transaction ....

Text

Figure: Caption

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 5 / 32

Page 6: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Proof of work

Figure: Caption

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 6 / 32

Page 7: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Mining rewards

Figure: Caption

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 7 / 32

Page 8: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Longest chain

Figure: Blockchain

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 8 / 32

Page 9: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Bitcoin: Advantages

Secure:transparencyno counterpart riskdecentralizedPrivacylow transaction cost

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 9 / 32

Page 10: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Bitcoing is Awesome! But...

Block creation time is very high 10 mins/block

Block confirmation time is very high 60 mins/blockcan only do one function: Cryptocurrencyuses too much of energy: by 2020 electricity equivalent to entireDenmarkEnters...

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 10 / 32

Page 11: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Bitcoing is Awesome! But...

Block creation time is very high 10 mins/blockBlock confirmation time is very high 60 mins/block

can only do one function: Cryptocurrencyuses too much of energy: by 2020 electricity equivalent to entireDenmarkEnters...

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 10 / 32

Page 12: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Bitcoing is Awesome! But...

Block creation time is very high 10 mins/blockBlock confirmation time is very high 60 mins/blockcan only do one function: Cryptocurrency

uses too much of energy: by 2020 electricity equivalent to entireDenmarkEnters...

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 10 / 32

Page 13: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Bitcoing is Awesome! But...

Block creation time is very high 10 mins/blockBlock confirmation time is very high 60 mins/blockcan only do one function: Cryptocurrencyuses too much of energy: by 2020 electricity equivalent to entireDenmarkEnters...

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 10 / 32

Page 14: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Introducing Ethereum

A planetary scale computer build on blockchain technologypermision-lessTuring complete language

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 11 / 32

Page 15: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Introducing Ethereum

A planetary scale computer build on blockchain technologypermision-lessTuring complete language

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 11 / 32

Page 16: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Turing Machine

Figure: Caption

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 12 / 32

Page 17: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Introducing Ethereum

A planetary scale computer build on blockchain technologypermision-lessTuring complete language

Begins the era of Decentralized app : Program that can run withoutfailure, without any downtime, censorship, fraud or third party inference

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 13 / 32

Page 18: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Introducing Ethereum

A planetary scale computer build on blockchain technologypermision-lessTuring complete languageBegins the era of Decentralized app

: Program that can run withoutfailure, without any downtime, censorship, fraud or third party inference

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 13 / 32

Page 19: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Introducing Ethereum

A planetary scale computer build on blockchain technologypermision-lessTuring complete languageBegins the era of Decentralized app : Program that can run withoutfailure, without any downtime, censorship, fraud or third party inference

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 13 / 32

Page 20: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

EVM: Ethereum Virtual Machine

Ethereum Blockchain isBlockchain with built in programming languagedecentralizedmassive database, where the current state of every account isstored EVM handles internal state and computationComputationis paid in Ether, per computation stepeach account object have:Its own internal statehave 32 byte key/value called storageCan call or send messages to other node

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 14 / 32

Page 21: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Bitcoin vs Ethereum

EthereumBitcoin

Figure: Bitcoin Vs EthereumRas Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 15 / 32

Page 22: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Basics of Ethereum

Ether: the underlying cryptocurrency of EthereumGas: Gas is a basic unit of computationSmart contract:

Pre-written logic (code)

stored and replicated on blockchainself executing by running the codecan update blockchaincan do transfer of assets,run code to make payment

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 16 / 32

Page 23: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Basics of Ethereum

Ether: the underlying cryptocurrency of EthereumGas: Gas is a basic unit of computationSmart contract:

Pre-written logic (code)stored and replicated on blockchain

self executing by running the codecan update blockchaincan do transfer of assets,run code to make payment

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 16 / 32

Page 24: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Basics of Ethereum

Ether: the underlying cryptocurrency of EthereumGas: Gas is a basic unit of computationSmart contract:

Pre-written logic (code)stored and replicated on blockchainself executing by running the code

can update blockchaincan do transfer of assets,run code to make payment

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 16 / 32

Page 25: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Basics of Ethereum

Ether: the underlying cryptocurrency of EthereumGas: Gas is a basic unit of computationSmart contract:

Pre-written logic (code)stored and replicated on blockchainself executing by running the codecan update blockchaincan do transfer of assets,run code to make payment

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 16 / 32

Page 26: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Account types

Externally Owned AccountsContract Accounts

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 17 / 32

Page 27: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Externally owned Accounts

Has ether Balance

Can send transactions (Ether transfer or trigger Contract code)Is controlled by private keyshas no associated code

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 18 / 32

Page 28: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Externally owned Accounts

Has ether BalanceCan send transactions

(Ether transfer or trigger Contract code)Is controlled by private keyshas no associated code

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 18 / 32

Page 29: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Externally owned Accounts

Has ether BalanceCan send transactions (Ether transfer or trigger Contract code)Is controlled by private keyshas no associated code

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 18 / 32

Page 30: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Contract Accounts

Has associated Ether balanceHas associated codecode execution is triggered by transaction or messages received fromother accountscan execute code of arbitrary complexity (Turing Completeness) andmanipulate data in blockchain

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 19 / 32

Page 31: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Transaction

Contains:receipt of the messagesignatureValue: amount of wei to be transferred from sender to recipientoption data field: which contains message to be send to recipientStartgas value:representing the maximum number of computationalsteps the transaction execution is allowed to take

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 20 / 32

Page 32: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Message

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 21 / 32

Page 33: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Mist

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 22 / 32

Page 34: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Mist: Introduction

Mist Ethereum wallet is a Desktop hybrid application which is bothEthereum node and client. Aim: to install mist and run a Faucet account

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 23 / 32

Page 35: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Discover MistDownload, install and start mist. You should see the following

Figure: Mist

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 24 / 32

Page 36: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Mistsynchronization to the main net would take a lot of the time, so youshould switch to the testnet

Figure: Testnet

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 25 / 32

Page 37: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Mist

Figure: CaptionRas Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 26 / 32

Page 38: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

MistAnd then you’ll see Mist syncing with test net

Figure: TestnetRas Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 27 / 32

Page 39: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

MistLets click on launch application

Figure: Caption

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 28 / 32

Page 40: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

MistCreate new account

Figure: Caption

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 29 / 32

Page 41: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Mist

Figure: Caption

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 30 / 32

Page 42: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Mist

Figure: Caption

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 31 / 32

Page 43: Introduction to Blockchain - Lecture 3: From Bitcoin to ...Bitcoin Blockchain: A Revision A Decentralized Ledger Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to

Bibliography

Ras Dwivedi (Indian Institute of Technology Kanpur) Introduction to Blockchain May 22, 2018 32 / 32