Fin385 - Su1 - SW

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 113

Smart Contract and

Blockchain in Finance
Dr LO Swee-Won
swlo@suss.edu.sg
+65 6248 0453
Class Schedule

• 14 March @ SR C.4.09 (Today)


• 21 March @ SR C.4.09
• 28 March @ SR C.4.09
• 04 April @ SR C.4.09
• 11 April @ SR C.4.09
• 18 April @ SR C.4.14
Assessments

• Quizzes 6%

• Participation 6%
• You will be evaluated on your reasoning, listening, and attendance

• Group-based Assignment (GBA) 38%


• Due date: 17 Apr

• End-of-Course Assessment (ECA) 50%


Aspects of Focus

• In-depth understanding of cryptocurrency and blockchain technology.

• Practical training on using console and smart contract programming.

• GBA:
Taxonomical analysis of the space of cryptocurrencies – a survey
incorporating your own way of classifying cryptocurrencies.

Form yourselves into groups of either 3 or 4. Maximum 4 per group.


Send me your members’ names (swlo@suss.edu.sg).
Questions?
Internet Economy
Money and social phenomenon; authority and trust; the role of Internet;
cryptocurrency vs blockchain vs fiat
Block 0
Satoshi: “I own
1 million bitcoins”

2009
Src: http://historyofbitcoin.org/
2 Key Aspects

564276

564275

564274

Cryptocurrency Blockchain
(Blocktree)
This is Life !
Bitcoin

• The underlying technology that makes bitcoin work is called


blockchain
• But what is a blockchain?
What is a ledger ?
o r e
ef
b
A owed B a goat

A signed
B agreed

Many verified

Source: refinitiv
Block #n
Date/Timestamp
Asset from X to A
(need to rewrite)

Block #2
Date/Timestamp
Asset from B to C
Ledger #1
or Block #1
Date/Timestamp
Asset from A to B
Allow to keep track of Asset or Property ownership
Transactions in blocks
This is live at the website.

What’s behind here?

Note the pace.


Src: https://blockchain.info/
Primary Bitcoins created

Src: https://blockchain.info/ Secondary Bitcoins’ transactions


Internet Economy
Back to the basics…
What is money?

• Standard descriptions
• Unit of account
• Means of payment
• Store of value
• Medium of exchange

• The first 3 features are manifestations of the fact that money


is a medium of exchange
Barter System
Barter System

• Dates back to 6000 B.C.


• Phoenicians bartered goods to those located in various other
cities across oceans.
• Babylonians exchanged goods for food, tea, weapons, and spices.
At times, human skulls were used as well.
• Romanian soldiers were paid with salt.
• In the Middle Ages, Europeans travelled around the globe to
barter crafts and furs in exchange for silks and perfumes.
• Colonial Americans exchanged musket balls, deer skins, and
wheat. 
Would you trade a new toy with
an old toy?
Stone Money of Yap

• Yapese had traditionally regarded stones carved in the shape


of a large disc with a hollow middle to be money.
• These stones represented wealth that a family or individual
possessed.
Money is a Social Phenomenon

• It is not just numbers


• It is not just pieces of paper
• Rather, it involves a community of users, who send it to each
other, normally with corresponding exchanges of goods and
services. These users do so because they (subconsciously) believe
that it will be readily accepted later from the community.
Autonomous Interactions

I want
I want
your
your fish
bread

Exchange
Measurements Arise

I want 1 kg
of fish
Problems with Autonomous Interactions:
Non-Coincidence of Wants

I want
I want fish
bread

No exchange
Problems with Autonomous Interactions:
Non-Existence of Units

I want
1 #@ of ?
fish

?
Qin Shi Huang

Introduced standardized units of measures

Introduced common currency

banliang coin
(1 liang ~ 16 g)

First Emperor of China


Unified China: 220 BCE
Social Order in Interactions of Autonomous Agents

• In social interactions of autonomous agents, social order is


provided by global signals
• There must be underlying agreement to facilitate
communication and exchange

• When the size of the community is small, it is relatively easy


to maintain such global signals

• When the size of the community is large, it is harder to


maintain such global states
The Tragedy of the Commons

• Individuals driven by self-interest act independently, deplete


or spoil common resource through their collective action.

• Solution:
• Governmental: Policy, control, “central administration” has no self-
interest.
• Non-Governmental: Definable resources, dependence on the
resources, community is small.

32
Autonomy and Authority

• Traditionally, global signals are provided by the authority

• The logic goes like this:


• Authority provides global signal for coordinative purpose
• The power of authority means that autonomous agents trusts the
stability and uniqueness of the signal
• The signal becomes common assumption amongst the autonomous
agents in their interactions
Money is a Social Phenomenon

• When people gathers, social structure arises… So does authority.


• Because there is a need for “trust”

What do you think


their role is?
The Role of Banks

• Data Storage and Records


• Regulated, Trusted

TRUST!
Sumerians

• Records of business transactions in the form of cuneiform


writing on clay tablets

Allocation of beers  Summary account of silver for the govenor 


Yap’s Monetary System

• The monetary system of Yap relies on an oral history of


ownership. Because these stones are too large to move,
buying an item with one simply involves agreeing that the
ownership has changed. As long as the transaction is
recorded in the oral history, it will now be owned by the
person it is passed on to and no physical movement of the
stone is required.

https://en.wikipedia.org/wiki/Yap#/media/File:Yap_Stone_Money.jpg
Silent Trade
As noted by the Greek historian Herodotus:

"The Carthaginians also tell us that they trade with a race of men who live in a part
of Libya beyond the Pillars of Hercules.

On reaching this country, they unload their goods, arrange them tidily along the beach,
and then, returning to their boats, raise a smoke.

Seeing the smoke, the natives come down to the beach, place on the ground a
certain quantity of gold in exchange for the goods, and go off again to a distance.

The Carthaginians then come ashore and take a look at the gold;
and if they think it represents a fair price for their wares, they collect it and go away;
if, on the other hand, it seems too little, they go back aboard and wait, and the
natives come and add to the gold until they are satisfied.

There is perfect honesty on both sides; the Carthaginians never touch the gold
until it equals in value what they have offered for sale, and the natives never touch
the goods until the gold has been taken away."
The Tragedy of the Commons

• Revisiting silent trade… the issue of trust between


Carthaginians and the natives – what do you think will
happen?

https://theoatmeal.com/comics/trust 39
Economy as a System

• At the micro level, men interact with each other, conducting their
everyday business of exchanging, buying and selling, lending and
borrowing, manufacturing, servicing, etc.

• These activities are not conducted independently from each other


• Locked into mutual needs and wants
Economy as a System

• At the macro level, regularities may be observed, measured,


analyzed, discussed, etc.

• E.g. depression, recession, inflation, interest rates, prices, etc.

• The economy is thus a system with (at least) 2 levels / scales of


reality, or a phenomenon with (at least) 2 scales of observations
• Interaction of agents result in macro level observations
• Agents observe macro level and adjust their actions
• Both scales affect each other in a feedback loop
What is the Purchasing Power of USD?
Structure in Trading / Exchange

When people trade or exchange,


they organize themselves into interactional structures.
Auctions
Different auction protocols.

Most common: English auction


Aka: Open Ascending Price auction

An auctioneer may announce prices,


bidders may call out their bids
themselves.

The auction ends when no participant


is willing to bid further, at which point
the highest bidder pays their bid.

If the seller has set a 'reserve' price and


the final bid does not reach that price
the item remains unsold.
The Microcosm of London (1808), an engraving of Christie's auction room
Structure of Stocks

• Agents pool resources

• A new entity, the corporation is created to own the pooled resources

• The corporation issues ownership shares to the agents

• The agents must trade these shares in the market


Structure of Futures
• A pair of counterparties enter into
a contractual mutual obligation so
trade an underlying asset in the -1 at t2 +1 at t2
future at a present set price
+1 at t1

• At a futures exchange, the contract Exchange


is standardized, thus allowing
participants to freely open/close or +1 at t3 -1 at t3
go long/short with each other.
-1 at t1
Structure of Bonds
Borrower

I promise $100
to repay
with interest

I trust you $110

Lender

This relationship is represented by a loan contract.


Lenders may trade the loan contract among themselves.
The Invisible Hand

The market will organize itself --- ?


Revisit: Money is a Social Phenomenon

• It is not just numbers


• It is not just pieces of paper
• Rather, it involves a community of users, who send it to each
other, normally with corresponding exchanges of goods and
services. These users do so because they (subconsciously) believe
that it will be readily accepted later from the community.
Revisit: The Role of Banks

• Data Storage and Records


• Regulated, Trusted

TRUST!
Revisit: Economy as a System

• At the micro level, men interact with each other, conducting their
everyday business of exchanging, buying and selling, lending and
borrowing, manufacturing, servicing, etc.

• These activities are not conducted independently from each other


• Locked into mutual needs and wants
Revisit: Economy as a System

• At the macro level, regularities may be observed, measured,


analyzed, discussed, etc.

• E.g. depression, recession, inflation, interest rates, prices, etc.

• The economy is thus a system with (at least) 2 levels / scales of


reality, or a phenomenon with (at least) 2 scales of observations
• Interaction of agents result in macro level observations
• Agents observe macro level and adjust their actions
• Both scales affect each other in a feedback loop
Break
The Role of Internet
What is the Internet?

• “The ocean was the first internet”

Router A Router B

https://en.wikipedia.org/wiki/Internet_protocol_suite
Example on MAC address
Example on IP address
UDP: User Datagram Protocol vs
TCP: Transmission Control Protocol

Client-Server
architecture
What is the role of Internet?

• Letters vs Email

• The issues of TIME and DISTANCE


What is the role of Internet?

• Traditional banking vs Internet banking

• Payment system, e.g., PayPal


Payment systems connect clients to banks and banks to banks
Payment systems handle transactions across networks
Payment systems may offer temporary credit which quickly
gets netted with bank accounts
PayPal as a payment system

src: https://www.paypalslots.ca/answers/how-does-paypal-work/
Peer-to-Peer Network

Router A Router B

https://en.wikipedia.org/wiki/Internet_protocol_suite
Peer-to-Peer Network

• An application layer protocol which depends on transport


layer protocols. May use UDP for lookups and TCP to send
whole resource objects.

• The opposite of a P2P network (e.g., BitTorrent, blockchain)


is a client-server network (e.g., YouTube, internet banking).
Bitcoin as a Digital Currency
Bitcoin

• The underlying technology that makes bitcoin work is called


blockchain
• But what is a blockchain?
This is Life !
Bitcoin and Blockchain

• A “Distributed Ledger Technology” (DLT) that operates on


top of a peer-to-peer network

• Enforces TRUST through:


• Consensus
• Cryptography
• Economic incentives
Revisit: The Role of Banks

• Data Storage and Records


• Regulated, Trusted

TRUST!
Revisit: Sumerians

• Records of business transactions in the form of cuneiform


writing on clay tablets

Allocation of beers  Summary account of silver for the govenor 


Revisit: Yap’s Monetary System

• The monetary system of Yap relies on an oral history of


ownership. Because these stones are too large to move,
buying an item with one simply involves agreeing that the
ownership has changed. As long as the transaction is
recorded in the oral history, it will now be owned by the
person it is passed on to and no physical movement of the
stone is required.

https://en.wikipedia.org/wiki/Yap#/media/File:Yap_Stone_Money.jpg
Bitcoin and Blockchain

• A “Distributed Ledger Technology” (DLT) that operates on


top of a peer-to-peer network

• Enforces TRUST through:


• Consensus
• Cryptography
• Economic incentives

Transaction
Bitcoin and Blockchain

• A “Distributed Ledger Technology” (DLT) that operates on


top of a peer-to-peer network

• Enforces TRUST through:


• Consensus
• Cryptography
• Economic incentives

Transaction
Bitcoin and Blockchain

• A “Distributed Ledger Technology” (DLT) that operates on


top of a peer-to-peer network

• Enforces TRUST through:


• Consensus
• Cryptography
• Economic incentives

Transaction
Bitcoin and Blockchain

• A “Distributed Ledger Technology” (DLT) that operates on


top of a peer-to-peer network

• Enforces TRUST through:


• Consensus
• Cryptography
Transaction
• Economic incentives
Transaction Transaction

Transaction

Transaction Transaction

Transaction

Transaction Transaction
Proof of Work

• Satoshi solves the problem of


“In terms of distributed computation, how may a network of nodes
agree on a state (e.g. attack, or retreat)” as follow
First Initiated Message and went through Proof of Work

Computed by A
via Proof of Work
Written by A

Pre-agreed
(in this case, happened to
be the genesis block)
Observing 4 zeros from Hashed result => a trusted message

From A

From A

Pre-agreed
(in this case, happened to
be the genesis block)
Replied and went through Hashing algorithm

Computed by B
via Proof of Work

Written by B
Receiving the replied message
Peer B (General B)
Observing 4 zeros from Hashed result => a trusted
message
Peer B (General B)

From B

From B
Bitcoin Network Nodes
Have you ever witness Bitcoin Network Nodes, live?
Distributed Computation: In General

• The network has 2 levels


• The local level of individual nodes
• The global level of the network system

• Normally, the network has a certain global goal, maintains a


certain global state; and this is achieved from local
interaction between the nodes
What’s the difference?
Bitcoin vs DBS (bank) What else?
Bitcoin Bank

Data is stored by all nodes in P2P Data is stored by the bank


network

Bitcoin is a medium of exchange to all Different Fiat Currencies, in general.


participants in the network
What’s the difference?
Bitcoin vs Paypal (payment system)
Bitcoin Payment System
Bitcoin network connects its Payment systems connect clients
peers together to banks and banks to banks
Bitcoin records transactions on Payment systems handle
its blockchain and thus has a transactions across networks
payment system baked into its
structure

Bitcoins are the currencies Payment systems may offer


themselves temporary credit which quickly
gets netted with bank accounts
Revisit: PayPal as a payment system

src: https://www.paypalslots.ca/answers/how-does-paypal-work/
Looking at the Bitcoin
blockchain explorer…
Depth of Autonomy: Internet

• Who owns the internet?


• Many parts
• no single part is totally indispensable
• example, lines are owned by telecommunication companies or
consortium (co-owned)
• Major internet bodies
• example, IAB, ICANN, IETF, etc.
Depth of Autonomy: Open Source

• Who owns open source software?

• Open source software are licensed by open source licenses

• Generally, these licenses aim to ensure that no one can


hoard and claim the code to be his own, restrict others’ use
of it, while at the same time enable and promote business
Social Structure in Developer Communities
• Lead figure
• Usually 1, who started the project
• Linux: Linus Torvalds
• Bitcoin: Satoshi Nakamoto

• Contributors
• Core - Make major decisions on direction of project
• Non-core
• Voluntary and global (with heterogeneous composition)

• Decision making (e.g., Segregated Witness, DAO hack)


• Non-authoritarian (benevolent dictator)
• Core influence
• Community consensus
People behind Technology
People behind Technology
Who’s who in Bitcoin Blockchain
Development
2008

2010

2012

Third Generation (for example Gregory Maxwell) sets up Blockstream.


Blockstream is one of the largest contributors of funding for Bitcoin Core,
the predominant bitcoin network client software.
Blockstream wanted “Segregated Witness”.
Blockstream  is responsible in developing an implementation of the Lightning Network 
What is Segregated Witness (SegWit) ?
Why Segregated Witness (SegWit) ?

More
Transactions
per Block !

Cater to 2 groups, ideally


Before Segregated Witness Implementation

65% of
a Transaction
After Segregated Witness Implementation
After Segregated Witness Implementation
Bitcoin BTC and Bitcoin Cash BCH
8Mb size
Variants of BTC pre-fork Bigger Blocks
due to Scaling Debate
more Centralisation ?
better for Mining Farm ?
Blockstream failed to honour
the New York Agreement
(which is, to activate Bigger Blocks
after activating SegWit, 1st Aug 2017
3 months later)
Looking at the Bitcoin
blockchain explorer again…
Find the transaction that used bitcoin to buy pizza
Over 2086 on the list, dated 23 Feb 2019. https://coinmarketcap.com/all/views/all/
BTCUSD
Cryptocurrencies are made up of Coins and Tokens
A Crypto-Coin has its own protocol
A token is riding on other’s protocol ( e.g. Ethereum ETH25)
“Tokens” EOS TRON VeChain Zilliqa

“Coins” Bitcoin Ether

Bitcoin Ethereum
Protocol Protocol Protocol

Bitcoin Ethereum
Technology Public
Blockchain
Public
Blockchain
So where are we now?
Bitcoin (digital currency) vs Fiat

Social Structure and Perceived Value

Autonomy

Trust and Authority

Data Storage and Record


Before we end:

You might also like