Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Blockchain & Smart Contracts

Blockchain & Smart Contracts

Avatar for Shumail Mohyuddin

Shumail Mohyuddin

January 25, 2018

More Decks by Shumail Mohyuddin

Other Decks in Technology

Transcript

  1. Outline • Ledger & Blockchain • Consensus • Proof of

    Work • Smart Contracts & their applications • DApps
  2. What we are talking about? Fields of Interest Ledger public

    vs. private Cross- Ledger Blockchain Graphs & Others Smart Contract Consensus Crypto- Currencies Business Model Scalability (…) Virtual Machine DApp Network
  3. Let’s focus on… Ledger public vs. private Cross- Ledger Blockchain

    Graphs & Others Smart Contract Consensus Crypto- Currencies Business Model Scalability (…) Virtual Machine DApp Network
  4. What is a ledger? Account Ledger Account Name: Big Money

    Bank Account Number: DE44 5001 0517 5407 3249 31 Date Description Debit Credit Balance 19.09.2017 Check from X 500 € 500 € 20.09.2017 Payment to Y 200 € 300 € 21.09.2017 Payment to Z 100 € 200 €
  5. What is a ledger? Bank Ledger Bank Name: Big Money

    Bank Date From To Amount Balance From Balance To 19.09.2017 DE44 1… DE44 2… 500 € 500 € 20.09.2017 DE44 2… DE44 3… 200 € 300 € 600 € 21.09.2017 DE44 2… DE44 4… 100 € 200 € 400 €
  6. What is a ledger? You can’t just “delete” a transaction

    in a bank ledger, you can just add transactions. Ledger TX1 from to amount TX2 from to amount TX3 from to amount TX4 from to amount TX5 from to amount
  7. Let’s focus on… Ledger public vs. private Cross- Ledger Blockchain

    Graphs & Others Smart Contract Consensus Crypto- Currencies Business Model Scalability (…) Virtual Machine DApp Network
  8. What is a Blockchain? Block 2 Block 3 Block 1

    TX1 from to amount TX2 from to amount TX3 from to amount TX4 from to amount TX5 from to amount Hash of previous block Hash of previous block Hash (…) Block x Hash (…) Blockchain
  9. Let’s focus on… Ledger public vs. private Cross- Ledger Blockchain

    Graphs & Others Smart Contract Consensus Crypto- Currencies Business Model Scalability (…) Virtual Machine DApp Network
  10. Blockchain Network Node (Computer) Client (Software) Block 3 Blockchain Block

    1 Block 2 TX1 TX2 TX3 TX4 TX5 Blockchain Synchronize Blocks (Protocol) Client Node Client Node Client Node Node Client
  11. Identity in the Network: Accounts Account = KeyPair PublicKey: Address

    (ID) PrivateKey: Signature Account = KeyPair PublicKey: Address (ID) PrivateKey: Signature sign transaction TX from to amount
  12. Approach • A peer to peer network which is Public

    • Announce your transaction to everyone • In your announcement, point to the specific account on the network you want to use. • Cryptographically sign your announcement with the same software key that is linked to that account so everyone knows the transaction is yours. • But… it almost works.
  13. The Problem? The previous approach lacks one thing: A way

    to make sure that if you broadcast 2 competing announcements (e.g. try to spend same funds twice), only 1 of your attempt counts. Known as “Double Spending” problem.
  14. Solution # 1: • Designate a party to timestamp the

    transactions and only include the transaction that came first. But… there’s a problem: A trusted 3rd intermediary
  15. Let’s focus on… Ledger public vs. private Cross- Ledger Blockchain

    Graphs & Others Smart Contract Consensus Crypto- Currencies Business Model Scalability (…) Virtual Machine DApp Network
  16. What is the Consensus? Parties that don‘t trust each other

    agree on the state of a system at a certain time. ✓
  17. History November 2008 An anonymous person publishes a paper explaining

    how to make electronic payments without a trusted central party like Chase or PayPal or the Federal Reserve. The paper proposes a breakthrough solution for consensus without any trusted central party That paper laid the birth of “Bitcoin”
  18. Breakthrough Solution • Let entities compete to be the “timestamper”

    • We can’t avoid the need for one, but we can avoid designating one in advance or using the same one for every batch of transactions • “Let entities compete.” – Sounds Interesting! • But what’s missing? A reward for winning. An asset.
  19. Breakthrough Solution • Let’s call that asset Bitcoin. • Let’s

    call the entities competing for the right to timestamp the latest batch of announced transactions “miners.” • Let’s make sure anyone can join this contest at any time by making the code and network open. • The algorithm is named as “Proof of Work” algorithm.
  20. Proof of Work 1. Every block includes a “cryptographic riddle”

    based on a very big random number. 2. The number is really, really hard to find. 3. So hard that the only way to find it is to use tons of processing power. 4. Difficult to solve – easy to validate (imagine Sudoku) 5. Difficulty makes sure that competitors have incurred a real financial cost. 6. Miners compete to solve that riddle as fast as possible. 7. Whoever wins the race to solve that riddle and becomes the designated time stamper for given batch of transactions, gets a reward 8. That way, miners don’t use that computation power for evil transactions.
  21. Proof of Work Node Client Node (Miner) Client Send Transaction

    Push into network Node (Miner) Client TX TX send transaction = request for state change
  22. Proof of Work TX Pool Node Client Node (Miner) Client

    Node (Miner) Client TX Pool TX TX Pool TX TX
  23. Proof of Work Node Client Node (Miner) Client Node (Miner)

    Client TX Pool TX Pool Blocknumber n+1
  24. Proof of Work Node Client Node (Miner) Client Node (Miner)

    Client TX Pool TX Pool Blocknumber n + 1
  25. Proof of Work Node Client Node (Miner) Client Node (Miner)

    Client TX Pool TX Pool Blocknumber n + 1
  26. Proof of Work Node Client Node (Miner) Client Node (Miner)

    Client TX Pool TX Pool Node Client „Confirmations“ for the transaction creator. Consensus reached!
  27. Proof of Work Node Client Node (Miner) Client Node (Miner)

    Client TX Pool TX Pool Node Client TX TX and so on…
  28. Let’s focus on… Ledger public vs. private Cross- Ledger Blockchain

    Graphs & Others Smart Contract Consensus Crypto- Currencies Business Model Scalability (…) Virtual Machine DApp Network
  29. What is Crypto currency? Crypto currencies are a new asset

    class that enable decentralized applications. X Don’t compare them with traditional currencies because it’s not about crypto currency vs fiat currency. Better to refer crypto currency as “crypto asset” So, Crypto assets are a new asset class that enable decentralized applications.
  30. Decentralized Applications A decentralized application is a way to create

    a service that no single entity operates. Allows you to do something you can already do today (like payments) but without a trusted central party.
  31. Only Payments? • No. It’s not about Payments anymore. •

    You can go “decentralized” way for any type of application. • Decentralized Application = dApp
  32. Let’s focus on Ledger public vs. private Cross- Ledger Blockchain

    Graphs & Others Smart Contract Consensus Crypto- Currencies Business Model Scalability (…) Virtual Machine DApp Network
  33. Smart Contracts • Proposed in 1996 by Nick Szabo as:

    “A smart contract is a computerized transaction protocol that executes the terms of a contract.” • A Smart Contract is a computer protocol/program intended to facilitate, verify, or enforce the negotiation or performance of a contract.
  34. What can Smart Contracts provide? • Autonomy – You’re the

    one making the agreement without involvement of a intermediary (a broker, lawyer or other intermediaries). • Transparency – Every state change becomes openly available. • Fairness – The source is openly available therefore the contract design can tell us if it is based on fairness or not. • Trust – Your documents are encrypted on a shared ledger. There’s no way that someone can say they lost it. • Backup – Imagine if your bank lost your savings account. On the blockchain, each and every one of your friends has your back. Your documents are duplicated many times over. • Savings – Smart contracts can save you money by removing the presence of an intermediary. • Accuracy – Automated contracts are not only faster and cheaper but also avoid the errors that come from manually filling out heaps of forms.
  35. Smart Contract Development import 'A.sol'; contract B isA{ uint public

    a; function B(){ a =0; } } Write Contract Code
  36. Smart Contract Development Compiler 0x6060604052 604051610450 380380610450 833981016040 528080518201 919060200150

    505b5b3360… VM Byte Code import 'A.sol'; contract B isA{ uint public a; function B(){ a =0; } }
  37. Smart Contract Development Deploy Transaction Compiler 0x6060604052 604051610450 380380610450 833981016040

    528080518201 919060200150 505b5b3360… TX from data amount import 'A.sol'; contract B isA{ uint public a; function B(){ a =0; } }
  38. Smart Contract Development “Contract Creation Request“ Compiler 0x6060604052 604051610450 380380610450

    833981016040 528080518201 919060200150 505b5b3360… Node Client VM TX from data amount TX import 'A.sol'; contract B isA{ uint public a; function B(){ a =0; } }
  39. Smart Contract Development Contract Address Compiler 0x6060604052 604051610450 380380610450 833981016040

    528080518201 919060200150 505b5b3360… Node Client VM TX from data amount Deploy Contract through transaction Push into network TX import 'A.sol'; contract B isA{ uint public a; function B(){ a =0; } }
  40. Smart Contract Development Compiler 0x6060604052 604051610450 380380610450 833981016040 528080518201 919060200150

    505b5b3360… Node Client VM TX from data amount TX Node (Miner) Client VM TX Pool TX Contract Address import 'A.sol'; contract B isA{ uint public a; function B(){ a =0; } }
  41. Smart Contract Development Compiler 0x6060604052 604051610450 380380610450 833981016040 528080518201 919060200150

    505b5b3360… Node Client VM TX from data amount Deploy Contract through transaction Push into network TX Node (Miner) Client VM TX Pool TX Contract Address Contract Mined! import 'A.sol'; contract B isA{ uint public a; function B(){ a =0; } }
  42. Smart Contract Development Compiler 0x6060604052 604051610450 380380610450 833981016040 528080518201 919060200150

    505b5b3360… Node Client VM TX from data amount Deploy Contract through transaction Push into network TX Node (Miner) Client VM TX Pool Node Client VM Contract Address import 'A.sol'; contract B isA{ uint public a; function B(){ a =0; } }
  43. Smart Contract Development Execute Contract Constructor to build local state.

    Compiler 0x6060604052 604051610450 380380610450 833981016040 528080518201 919060200150 505b5b3360… Node Client VM TX from data amount Deploy Contract through transaction Push into network TX Node (Miner) Client VM TX Pool Node Client VM Contract Address import 'A.sol'; contract B isA{ uint public a; function B(){ a =0; } }
  44. Contract Communication TX from to data Node Client VM TX

    Send Transaction to Contact Address Push into network Call method, params Contract Address
  45. Contract Communication TX from to data Contract Address Node Client

    VM Send Transaction to Contact Address Push into network TX Call method, params Contract Address Node (Miner) Client VM TX Pool TX
  46. Contract Communication Node Client VM Node (Miner) Client VM TX

    Pool Node Client VM TX from to data Send Transaction to Contact Address Push into network TX
  47. Contract Communication Execute contract method, build local state. Node Client

    VM Node (Miner) Client VM TX Pool Node Client VM TX from to data Send Transaction to Contact Address Push into network TX
  48. Let’s focus on… Ledger public vs. private Cross- Ledger Blockchain

    Graphs & Others Smart Contract Consensus Crypto- Currencies Business Model Scalability (…) Virtual Machine DApp Network
  49. From Central to De-Central Server Client Client Client Data State

    Client Data State Client Data State Client Data State Central Decentral
  50. A Decentral Application Node Client VM Application User-Data Files (…)

    Node Client VM Application User-Data Files (…) Blockchain Sync P2P Messaging P2P File Exchange
  51. Let’s focus on… Ledger public vs. private Cross- Ledger Blockchain

    Graphs & Others Smart Contract Consensus Crypto- Currencies Business Model Scalability (…) Virtual Machine DApp Network
  52. Use-Case Characteristics Transparency & Decentralization - Everything is visible -

    Public validation - Public vs. Private – sense of obscurity? - Everybody, anything, any time - Unstoppable Fairness & Trust Collaboration & Motivation Efficiency & Maintenance - Incentives for stakeholders - Costs for services - Benefit should be given - Multiple parties establish trust - Who is allowed to do what? - When is who allowed to do what? - Data can only go in (no outside calls) - One cannot argue with a contract - Mistakes are unchangeable - Higher complexity = Higher cost - Complexity restrictions
  53. Smart Contract Challenges Usability - End-Users and: - The technology

    (processes) - Accounts - Assets - Lack of (good) user interfaces Regulation Risk Volatility - Identity - Law Situation - Governance - Volatility of the currencies - Volatility of the software - Restriction to Ledger - Lack of standards
  54. What we are talking about? Fields of Interest Ledger public

    vs. private Cross- Ledger Blockchain Graphs & Others Smart Contract Consensus Crypto- Currencies Business Model Scalability (…) Virtual Machine DApp Network