Money & Payments III - Blockchain & Smart Contracts: Nitin Yadav

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Money & Payments III – Blockchain & Smart Contracts

Nitin Yadav

Brain, Mind and Markets Lab


The University of Melbourne

Semester 2, 2019
Quiz 2

● 5 multiple choice questions


● 10 minutes to complete
● Worth 2% of your final mark
○ All multiple choice questions are weighted equally
● Please enter your name and student number correctly
○ Your marks will be recorded against your student number
● Please use your Unimelb student account to login to Google
● Complete on your own!

2
Announcement for tutorials

● Please shutdown your jupyter notebooks when you are not using the system
○ Some students still have multiple week-1 notebooks running on their accounts
● In tutorial 2, please don’t request more than 10,000 Wei (in total)
○ You cannot exchange these coins for fiat currency!
○ Please don’t abuse the system
■ Try as much as you wish, but please return excess coins back to the Faucet
■ Otherwise, we will do it ourselves (Proof-of-Authority!)

3
Today’s lecture

1. Smart contracts
a. Revisiting the idea of blockchain
b. Self-executing contracts
2. Applications
a. E-estonia
b. Trade finance
3. Assignments 1 & 2
4. Guest lecture

4
1. Smart contracts

5
Blockchain

● Last week we saw how a blockchain can be used to create


a public distributed ledger
○ The blockchain stored cryptocurrency transactions
● Blockchains not limited to storing payment transactions only
○ Cryptocurrency blockchains are only one specific use case of a blockchain
○ We can use blockchains to store (any) structured data
○ Where will this be beneficial? Think about the properties of blockchains:
■ Immutability of past blocks
■ Robustness {
● Stored on a network 'to': '0x479aA362A6c7522554A59C1d8903eFDBb23329c8',
'from': '0x46390b352Be56d796B005966b8EADaa58f220e7D',
■ No central authority 'value': 500,
● Multiple entities need access 'nonce': 12,
...}
■ Security
6
Blockchain

(Let us revisit the blockchain slide from last week)


In this lecture we extend the definition of
transactions to include any structured data.
Common components of a public blockchain:

1. A peer-to-peer network that transmits and stores transactions


2. A set of rules defining what is a valid transaction
3. Secured blocks that provide a ledger of all past transactions
4. A consensus algorithm for decentralised control
5. A sound incentives scheme for maintenance and security
Q: But then how to validate a transaction?
A: Via pre-defined rules in (smart) contracts

7
Blockchain

Why store data on a blockchain? Data in Hash of


traditional data Blockchain
storage
● What does blockchain provide: Any change in data will require a change in its hash in
○ Tamper-proof timestamped data the blockchain. Authorised updates in the data can be
recorded as new hashes in subsequent blocks.
○ Decentralised consensus
○ Transparency
● What about privacy?
○ Stored data can be encrypted so that only authorised users can access it
● What if data is large?
○ One does not have to store all the data on the blockchain
■ Storing only hashes can establish tamper-proof property (see figure)
● Is stored data always correct?
○ This may not be the case, one has to trust the external entity recording the data
○ This is a different issue from the tamper-proof property 8
Blockchain

Two important things to consider:

1. How to manage the custom data in a blockchain (i.e., inside the system)?
○ Rules for verifying currency transactions in Bitcoin and Ethereum are pre-specified
○ If one owns custom data, how can one define rules for valid transactions?
i. Smart contracts
2. Who provides and checks the correctness of the data (i.e., outside the system)?
○ There was no need for external verification in Bitcoin/Ethereum as there was minimal
interaction with the external world
i. New currency generated within the system
ii. Exchanges involving fiat currency or goods are outside the system
○ What if the custom data requires verification (e.g., trade records, vehicle details, etc)?
i. “Oracles”: You can ask external entity to verify data correctness

Note: Smart contracts provide a richer set of functionality that we will discuss next. 9
Smart contracts

● Technically, it is a program that may update blockchain data


● Automatic execution when conditions are met
○ Think of it as “digital promises”
● Rule based agreement between one or more parties
○ Transactions are executed only when the specified conditions are met
● They live on the blockchain!
○ Immutable
○ Decentralised with multiple copies
● Smart contracts allow for more powerful systems to be built on blockchains
○ We will see examples below

10
Smart contract example from tutorial
If the conditions are met:
● Requested amount less than the limit
● Faucet still has funds
Faucet Then the Faucet promises to transfer the requested
amount of funds.
withdraw(uint amount)
:condition -> amount < limit

Request Ether
transaction
(signed)

Transfer Ether
transaction

User
11
Smart contracts

● What kind of programs can one write with smart contracts?


○ Depends on the platform
○ Bitcoin
■ Transactions have a script language that can be used to define conditions on spending BTC
● Bitcoin scripting is not a complete programming language (e.g., loops are not allowed)
○ Ethereum
■ Has the concept of a “virtual machine”
■ Provides a complete programming language (loops are allowed)
■ How to prevent someone from triggering an infinite loop?
● Each transaction provides a limit on gas
○ Hyperledger Fabric
■ Backed by the Linux foundation and IBM
■ Does not have a cryptocurrency component

Note: List of platforms is not exhaustive. 12


Smart contracts (Ethereum)

How do they work?

● One writes a smart contract in a programming language (e.g., solidity)


○ One can define variables to store custom data along with rules to update them
● The contract owner deploys the smart contract on the system
○ Upon deployment the contract gets its own public address
● Users trigger contract’s functionality by sending transactions to its address
○ The contract will execute the required functionality on valid transactions
○ The contract can interact with other contracts
○ Execution of a functionality costs gas
○ Contract executions may update the contracts internal data
● A contract can be deleted
○ In this case, a gas refund is issued to the contract owner
13
Smart contract example from tutorial
A transaction that updates the blockchain A “read-only” transaction

Faucet Car

0xe09639Bd8DEfd6A8868F84e6010DB9c6cC49Ac74 0xe09123da4….
withdraw(uint amount) getColor()
:condition -> amount < limit

Request Ether Request car


transaction color
(signed)

Transfer Ether
transaction Car’s color

Private Key: 3828a2f90c796…..


Public address: 0xdCB5920d8b7…. Public address: 0xdCB5920d8b7….
14
Tokens

● Tokens are smart contracts


● One can define properties of tokens
○ Fungible vs non-fungible (see lecture 1)
○ Mintable
○ Transferrable
○ Burnable
● Different types of tokens (see lecture 2)
○ Utility tokens (see assignment 1 & 2)
■ Fungible tokens that are used to access a particular service
○ Asset tokens (e.g. the car tokens from tutorial 2)
■ Non-fungible tokens that are used to establish ownership of an asset
■ Asset could be a physical or virtual entity, equity, voting right, etc.
○ Currencies
15
Trust in smart contracts

One has to trust the code (i.e., the programmer)

● Software may have bugs


● Reentrancy bug (Ethereum)
○ Reported in a DAO smart contract that had two lines of code in wrong order
■ DAO stands for “Decentralised Autonomous Organisation”
○ An attacker could repeatedly withdraw tokens (re-enter the line that executes the withdrawal)
■ An (anonymous) attacker did withdraw 3.6 M Ether out of a DAO
■ A community group called the “Robin Hood” group used the same strategy to secure the
remaining funds
● No implemented checks for unsupported tokens
○ A smart contract should either implement a refund function or reject transactions with
unsupported tokens
16
2. Applications

Note: We do not endorse or promote any of the mentioned applications. Our purpose is to show potential use cases of the
technologies discussed in lecture 2.
17
E-estonia

“I should have called the Estonians when we were setting up our health care website.”
- Barack Obama in 2014.

● Estonia
○ A northern European country with a population of around 1.3 M
○ Most digitally advanced society (according to “Wired”)
■ 98% of government interactions are online
■ https://www.wired.co.uk/article/digital-estonia
○ First country to hold elections over of the internet
○ First country to provide e-residency
■ Allows non-estonians to access Estonia’s digital services
● Start a company, access banks, lodge tax returns, etc.

18
E-estonia
● Each citizen has a card that contains their private key
○ This establishes a secure digital identity (recall the cryptography slides from week 2)
○ Works across government and private systems
○ Digital signatures saved ~20 minutes per transaction (according to a World Bank report)
○ Used for:
■ Online banking
■ Taxation
■ Health records and drug prescriptions
■ Voting

Sources: http://documents.worldbank.org/curated/en/896971468194972881/pdf/102725-PUB-Replacement-PUBLIC.pdf 19
E-estonia

● X-Road
○ Internet based decentralised system to allow for information sharing
■ Participating entities retain ownership of data
○ Around 900 (as of 2013) participating entities, 70% government and 30% private
○ Around 67% (as of 2013) of queries were automated exchanges between systems
○ Backed by policy: Requesting information already stored via X-Road is prohibited

https://www.pwc.com/gx/en/services/legal/tech/assets/estonia-the-digital-republic-secured-by-blockchain.pdf 20
E-estonia
● Blockchain
○ First country to have a nation-wide blockchain system
○ Hashes are stored in the blockchain
■ Provides scalability and speed
■ Data resides on respective systems
○ Data breaches are detected instantly
○ Provides a consistent view of the data
■ E-health records case notes, doctor visits, test results, drug prescriptions and access log
■ Public safety
● Driving license information recorded against digital id
● Time to access information reduced from 15-20 minutes (using radio) to ~2s (using
blockchain)
■ Many others → https://e-estonia.com/solutions/

Sources: http://documents.worldbank.org/curated/en/896971468194972881/pdf/102725-PUB-Replacement-PUBLIC.pdf, 21
https://www.pwc.com/gx/en/services/legal/tech/assets/estonia-the-digital-republic-secured-by-blockchain.pdf
Trade finance
● Incorporates use of financial products to facilitate international trade
● WTO estimates that around 80 to 90% of world trade depends on trade
finance
● Suppose an Australian importer wants to import an exotic fruit from an
exporter in San Marcos
○ The importer does not trust the exporter, hence, does not want to pre-pay
○ The exporter will not ship the fruit unless she is guaranteed payment
○ The shipping involves multiple ports
● Solution
○ The importer can get a letter of credit from its bank
■ Guarantees release of payment conditional on
shipment
○ The exporter provides bills of lading as proof of
shipment Australian Imports. Source: https://oec.world/en/profile/country/aus/
22
Source: https://www.wto.org/english/thewto_e/coher_e/tr_finance_e.htm
Trade finance

● Traditional methods are tedious, inefficient, and susceptible to fraud


○ Documents are generally checked manually
○ Information is scattered across different systems
○ No central authority In practice: https://we-trade.com/

● Blockchain-based solution
○ Generation of letters of credit
■ Time can be reduced from 7 to 10 days to under 4 hours!
○ Automatic verification of shipping information
■ Tracking of goods recorded on blockchain
○ Automatic release of payments
■ Using smart contracts
○ Possible drawback is that all components need to be on blockchain
○ Major Australian banks are trialing blockchain-based solutions

23
Source: https://cib.db.com/insights-and-initiatives/flow/trade_finance_and_the_blockchain_three_essential_case_studies.htm
3. Assignments 1 & 2

24
Assignments 1 & 2
● A second-hand car market on blockchain
○ Underlying problem is information asymmetry
■ Buyer does not know the quality of the car but seller knows if her car is “good” or “bad”
■ Buyer knows the overall proportion of good and bad cars in the economy
○ How can a blockchain help?
■ Stores vehicle’s attributes on blockchain
■ Reduces (aggregate) information asymmetry
■ Allows for smart contracts (conditional offer price)
○ Buyers have incentives to trade in the “blockchain market”
■ Need a BMM Coin (token) to place an offer in the blockchain market
● Why not buy in a traditional market?
○ Think about information asymmetries!

Assignment 1: In a ICO of BMM Coins, how much should a buyer be willing to pay to get access to the
blockchain market? More details in next week’s tutorial...
25
4. Guest lecture

26
Volt Bank

● Digital-only bank with full banking


license (granted earlier this year)
○ It is the first new bank to get a full
banking license in Australia since early
2000s

27
Dominic Ng

● Senior business and service designer and strategy


implementation specialist at Volt Bank
● He uses his understanding of how organisations work
to help design and transform the way they operate to
better serve their clients, across their organisational
lifecycle from start-up, through growth, and into
maturity
● Dominic is also a fervent champion of human–centred
design, and the way it helps us innovate to transform
the way we interact, learn and conduct business

28
Next week

● Lecture
○ Quiz 3
○ Financial advice
● Tutorials
○ Preparing for the assignment
● Mandatory readings:
○ “IBM's Blockchain Consortium With The Seam Deploys 'Hyperledger' For Cotton Trading” by
Roger Aitken on Forbes.com
https://www.forbes.com/sites/rogeraitken/2017/01/07/ibms-blockchain-consortium-with-the-seam-deploys-hyperledge
r-for-cotton-trading/#481e77797e8a
○ “Trade finance and the blockchain -e fin three essential case studies” by Deutsche Bank
https://cib.db.com/insights-and-initiatives/flow/trade_finance_and_the_blockchain_three_essential_case_studies.htm

29

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy