How to use in enterprise world?

An exploratory research on the possibilities and limitations of implementing blockchain based solutions in the real estate industry

Master thesis title How to use blockchain in enterprise world? - An exploratory research on the possibilities and limitations of implementing blockchain based solutions in the real estate industry

Student Hunor Vadasz-Perhat

Student ID 64442

University Roskilde University (RUC) Universitetsvej 1., Postbox 260, 4000 Roskilde, Denmark

Department Computer Science and Informatics (M.Sc.)

Supervisor Professor John Patrick Gallagher

1

Abstract

The real estate market has an importance on the overall economy. A real estate crisis that the world has recently experienced lead to long lasting and serious consequences both on a micro and macro level. Besides, such crashes that tend to happen the real estate market also suffers from inefficient transaction processes, problems with transparency, illiquidity and high transaction costs.

The goal of this master thesis is to examine the possibilities and limitations of implementing Blockchain based solution for the real estate industry. Blockchain is a new and emerging technology with potentials that can have an impact on several areas of life, including the real estate market.

In order to be able to answer the research question that is formulated in the thesis there will be provided an extensive knowledge about Blockchain functionality and it potentials together with its challenges. Furthermore, a background theoretical knowledge will be provided about the real estate market, more precisely about the real estate management process. After the theoretical introduction the thesis will look at how and in which phases of the real estate management process Blockchain could be used. Technical and non- technical limitations will be discussed as well.

One of the conclusions of the thesis is that the Blockchain technology has potential and is capable of improving inefficiencies of the real estate market processes but the technology and the topic needs to be investigated deeper and also from an interdisciplinary point of view.

2

Table of contents

Part I - Introductory chapter ...... 7 1. Introduction ...... 7 1.1 Problem statement ...... 7 1.2 Research questions ...... 8 1.2.1 Main research question ...... 8 1.2.2 Sub questions ...... 8 1.3 Structure ...... 8 Part II - Theoretical background ...... 11 2. Theoretical background - Blockchain Technology ...... 11 2.1 Introduction ...... 11 2.2 Short history of blockchain and payment systems ...... 11 2.2.1 “The oldest block chain” ...... 11 2.2.2 Satoshi Nakamoto ...... 12 2.2.3 DigiCash ...... 13 2.2.4 HashCash ...... 13 2.2.5 B-money ...... 13 2.3 Introduction to blockchain technology ...... 14 2.3.1 Definition ...... 14 2.3.2 Key characteristics ...... 14 2.3.3 Structure ...... 15 2.3.4 ...... 16 2.4 Taxonomy of blockchain ...... 19 2.4.1 Public blockchain ...... 19 2.4.2 Consortium blockchain ...... 19 2.4.3 Private blockchain ...... 19 2.4.4 Comparison of types of ...... 19 2.5 Distributed system ...... 20 2.5.1 CAP theorem ...... 22 2.5.2 Byzantine Generals problem ...... 25

3

2.6 Consensus algorithms ...... 26 2.6.1 Proof of Work (PoW) ...... 27 2.6.2 Proof of Stake (PoS) ...... 29 2.6.3 Comparison of consensus algorithms ...... 30 2.7 Uses cases and applications ...... 30 2.7.1 Exchange of value ...... 30 2.7.2 Internet of Things (IoT) ...... 31 2.7.3 Decentralized markets ...... 31 2.7.4 Supply chain management ...... 31 Part III - Prototype ...... 32 3. Prototype - Blockchain and Decentralized Application (DApp) ...... 32 3.1 Introduction ...... 32 3.2 Blockchain - proof of concept ...... 32 3.2.1 Block class ...... 32 3.2.2 Hashes ...... 33 3.2.3 Blockchain class ...... 34 3.2.4 Additional methods ...... 34 3.2.5 Validation ...... 35 3.2.5 Mining ...... 35 3.3 Decentralized Application - proof of concept ...... 37 3.3.1 Decentralized applications ...... 38 3.3.2 Ethereum ...... 39 3.3.3 Traditional vs Blockchain based Web App ...... 39 3.3.4 Smart Contract ...... 40 3.3.5 DApp development ...... 43 3.3.6 The Gas system ...... 48 3.3.7 Walkthrough of prototype ...... 50 Part IV - Theoretical background - Real estate ...... 56 4. Theoretical background - Real estate management process ...... 56 4.1 Introduction ...... 56 4.2 Commercial real estate ...... 56 4.3 Stakeholders ...... 57 4.3.1 Occupiers ...... 58 4.3.2 Government ...... 58 4.3.3 Investors ...... 58 4.3.4 Funders ...... 58 4.3.5 Contractors and Designers ...... 58 4.3.6 Brokers ...... 58 4.3.7 Advisors ...... 59 4.4 The acquisition process in real estate life cycle ...... 59

4

4.4.1 Preparation period ...... 59 4.4.2 Marketing period ...... 59 4.4.3 Due diligence period ...... 59 4.4.4 Exchange to completion ...... 59 4.4.5 Process flow ...... 59 4.5 The operating process in real estate life cycle ...... 61 4.5.1 Commercial management ...... 61 4.5.2 Technical management ...... 61 4.5.3 Administrative management ...... 62 4.5.4 Promotional management ...... 62 Part V - Discussion ...... 63 5. Discussion ...... 63 5.1 Introduction ...... 63 5.2 The acquisition process ...... 63 5.2.1 Digitalization through smart contract ...... 63 5.2.2. Efficient financing mechanism ...... 75 5.3 The operating process ...... 79 5.3.1 Digital lease contracts ...... 79 5.3.2 Summary ...... 81 5.4 Technical challenges ...... 82 5.4.1 On-chain storage ...... 82 5.4.2 Off-chain storage ...... 83 5.4.3 Denial-of-Service attacks ...... 84 5.4.4 DAO hack ...... 84 5.4.5 Scalability ...... 85 5.5 Ten-step decision path ...... 85 5.6 GDPR ...... 86 5.7 DApp development ...... 87 5.8 Swedish Lantmäteriet ...... 88 Part VI - Conclusions ...... 91 6. Conclusions ...... 91 Part VII - Research limitations ...... 93 7. Research limitations ...... 93 7.1 The hype around Blockchain ...... 93 7.2 The depth of the thesis ...... 93 7.3 Regulations and law ...... 93

5

7.4 Complexity ...... 93 7.5 Lack of real world use cases ...... 94 Bibliography ...... 95 Appendices ...... 100 Appendix A - IPF ...... 100 Appendix B - Blockchain prototype ...... 105

6

Part I - Introductory chapter

1. Introduction

Internet gave us the possibility to transfer information in a cheap and quick manner without intermediaries. We use the internet to send and exchange texts and images and Blockchain platforms can have similar advantages if we want to send money to each other.

The real estate industry is characterized by high transaction costs, land use regulations and slow reaction to the changes in demand due to its unique complexity. The market efficiency is therefore low and the market for selling and buying is highly segmented and localized. There is a greater demand for transparency. Even though the information is getting digitized access to this is highly restricted and fraud or inaccuracies are just the daily problem we need to face. According to Deloitte (2017) the Blockchain technology might be able to tackle these issues in the long run.

Blockchain in simple terms is a peer-to-peer network where there is no need for a central figure in order to make transactions and every transaction is recorded in the distributed ledger which is publicly available to every participant on the network. The technology has the potential to optimize processes and avoid the middleman.

Furthermore it is claimed that Blockchain has an endless amount of possibilities to change our lives in different areas and on different scales for the better. The technology powered by the distributed and shared ledger can make interactions quicker, cheaper and safer from banking payments to voting systems.

The hype is indeed getting bigger and more actors from individuals to national banks are getting into this topic. Due to the above mentioned positive characteristics of the Blockchain technology there might be possibilities for the real estate industry. In order to get a better picture in this research I will explore the possibilities of the integration of Blockchain technology in real estate. To be more precise the research has a limited focus on which phase of the real estate management process the Blockchain technology could have a potential implementation.

1.1 Problem statement Real estate as a sector is characterized by inefficient processes, not transparent markets and by large the lack of technological developments. The Blockchain technology might solve the above mentioned inefficiencies to a certain level which could

7 be beneficial for the industry. The scale of such an influence is the topic of ongoing discussions but it is certain that foundational benefits could be made. Considering all the above the problem statement is:

The blockchain technology could have the basic technological principles that could change the functioning of the real estate process which is influenced by bad practices.

1.2 Research questions

1.2.1 Main research question Based on the problem statement the main research question is:

What are the possibilities and limitations of implementing blockchain based solutions in the real estate industry?

1.2.2 Sub questions Sub questions will enable us to understand the two fields better which are Blockchain and Real estate. The following questions came up regarding the two fields of interest:

Blockchain: ● What is Blockchain? ● How does it work? ● What are the use cases and applications today? ● Where could the Blockchain technology be used in real estate? ● What are the challenges of using Blockchain in real estate?

Real estate: ● What is real estate? ● What is the real estate management process and which are the phases? ● What stakeholders do play a role in the whole process? ● In which phase could Blockchain be used?

1.3 Structure The master thesis is considered to be exploratory by its nature since there was more focus put on to get theoretical understanding and explanation of the given phenomenon namely Blockchain technology in real estate rather than focusing and testing any already existing theoretical or practical approaches.

8

In the following, the different phases and their research goal will be shortly described: ● Part 1. - Giving an introduction to the thesis and describe the problem statement, the research questions and the structure ● Part 2. - Providing a theoretical background into Blockchain technology: ■ Related history ■ Definition ■ Basic structure ■ Cryptography ■ Taxonomy of blockchain ■ Distributed systems and related issues ■ Consensus algorithms ■ Use cases of Blockchain ● Part 3. - Developing a proof of concept: ■ Developing a simple Blockchain app with JavaScript ■ Developing a simple Decentralized Application with Ethereum based development stack ● Part 4. - Providing a theoretical background into real estate. More precisely to the real estate management process: ■ Definition ■ Real estate management process ■ Stakeholders ■ The acquisition process ■ The operating process ● Part 5. - Discussion on the possible implementations of Blockchain in particular real estate management phases and on technical and non-technical challenges: ■ Digitalization via smart contracts ■ Ricardian contracts ■ Crowdfunding as a financing tool ■ Digital lease contract ■ On-and off-chain storage ■ Denial-of-Service attacks ■ DAO hack ■ Scalability ■ Ten-step decision ■ Path ■ GDPR ● Part 6. - Drawing conclusions ● Part 7. - Highlighting some limitations of the research

9

10

Part II - Theoretical background

2. Theoretical background - Blockchain Technology

2.1 Introduction The aim of this part is to provide a technological and theoretical background to the blockchain technology. This part will look at the following topics: ● Short history of blockchain and related technologies ● Definition, basic structure and key characteristics of blockchain ● Basic cryptography: symmetric cryptography, asymmetric cryptography and digital signature ● Types of blockchain and a comparison ● Distributed systems and their issues and possible solutions ● Consensus algorithms and a comparison ● Blockchain use cases and applications

2.2 Short history of blockchain and payment systems

2.2.1 “The oldest block chain” In 1991 Staurt Haber and W. Scott Stornetta were working on a chain of blocks that secured by cryptography so that nobody could interfere with the timestamps of the documents (Haber, Stornetta, 1991).

Fig. 2.1 Linked timestamping. From Narayanan, Bonneau, Felten, Miller, Goldfeder, 2016, p. 16.

11

As shown in Figure 2.1, a linked timestamping is a secure process which keeps track of the creation and modification of a document. By secure we mean that it would not be possible to change the document even for the owner once it is created. The integrity of the timestamp would provide a proof for the document not being compromised. Merkle trees were added later on in order to improve efficiency by allowing several document certificates to be collected in one block as shown in Figure 2.2.

Fig. 2.2 Efficient linked timestamping. “Arrows represent hash pointers and dotted vertical lines indicate time intervals”. From Narayanan et al., 2016, p. 16.

2.2.2 Satoshi Nakamoto But it was not until 2008 that blockchain got relevance thanks to Satoshi Nakamoto, who is credited as the creator behind blockchain and also believed that he was working on Bitcoin. Satoshi Nakamoto is considered to be a pseudonymous name and the real person behind the name is still a mystery until this day. Back in 2008 Nakamoto published a paper where he described the digital currency known as bitcoin (Nakamoto, 2008). Nakamoto created a website with the domain name bitcoin.org and worked on the software until mid-2010. The very first version of bitcoin was released on the 9th of January in 2009. Six days earlier on the 3rd of January the network started to exist where Nakamoto mined the genesis block of bitcoin. The transaction text said “The Times 03/Jan/2009 Chancellor on brink of second bailout for banks” (Elliot, 2009). The text referred to a title of an article that was published in The Times and it is described as a rather harsh comment and also a political stand against the fractional reserve banking system and its instability that caused huge casualties for the society.

The concept of digital currency existed before bitcoin already back in the 1980s and from that time on. Now we are going to look at some solutions and understand what their impact was.

12

2.2.3 DigiCash David Chaum, an american computer scientist and a pioneer in cryptography is widely known for developing ecash. His proposal with introducing the digital cryptographic signature called blind signature made it possible to get a digital currency from a bank and later on spend that amount in a way that the bank or any other third party could not trace it (Chaum, 1985). In 1990 he founded an electronic cash company called DigiCash.

2.2.4 HashCash Another related concept is hashcash which was introduced by Adam Back (Back, 1997). The goal was to control email spam. The basic idea was that a legitimate user needed to compute a hash which served as a proof that they used a significant amount of computing resources in order to send their email to the receiver. If someone with a bad intention such as a spammer wanted to send a large quantity of emails then it would not be possible to compute the hashcash. This concept has become popular because the mining process in bitcoin is using the concept of computing hash functions as PoW (Proof of Work) which was introduced in hashcash.

2.2.5 B-money B-money was introduced by Wei Dai which practically had all the attributes of a modern cryptocurrency which is “...a scheme for a group of untraceable digital pseudonyms to pay each other with money and to enforce contracts amongst themselves without outside help” (Dai, 1998). After breaking it down the core concepts that were later on implemented in bitcoin are the following: ● It requires an amount of computational work which is also known as Proof of Work (PoW) ● The community holds a ledger that is shared by every member ● The computational work that is done is verified by the whole community ● There is a reward for doing the computational work ● In case of exchange there is a commonly shared book keeping system (also known as ledger) which is secured by cryptographic hashes ● Contracts are broadcasted to all members on the network ● Transactions are signed with digital signatures

The list could carry on since there were a lot of milestones on the way. What we can conclude is that each of these concepts had their own flaws and issues. It was only in 2009 when bitcoin as the first practical implementation was introduced that solved various issues. The most important innovative idea of bitcoin was to provide a mechanism in which a list of blocks that are ordered and linked together would be made up by

13 transactions and these transactions would be secure cryptographically because of the use of the Proof of Work mechanism. As we can see the development of the idea of digital currency was a rather long process with many concepts introduced along the way. Through history the different ideas and concepts from electronic cash systems to distributed systems were combined and it created the possibility for the creation of blockchain technology and digital currencies.

2.3 Introduction to blockchain technology

2.3.1 Definition A blockchain is a growing list of records, called blocks, that are linked using cryptography while each block contains a cryptographic hash of the previous block, a timestamp and transaction data (Narayanan et al., 2016). It is “simply a chronological database of transactions recorded by a network of computers” (Wright, De Filippi, 2015). The blockchain technology puts data blocks together in blocks. Every new entry is stored in a new block. If the chain gets manipulated the link of the chain will break and the attempt for the manipulation would be detectable. A blockchain can operate as a distributed system. In this scenario the data is not stored in a central manner but it is distributed on the network nodes of the system. A copy of the digital transaction ledger is owned by every individual participating in the peer-to-peer network. There is no central authority who would validate the transactions but automatic mechanisms (Voshmgir, Kalinov, 2017). Through this approach every node which are the individual participants have the updated knowledge of transactions and it is not necessary to contact a central authority.

2.3.2 Key characteristics Decentralization: contrary to the traditional model a third party is not needed. The consistency of data in distributed network is reached by the use of consensus algorithms.

Persistency: transactions almost impossible to delete or rollback once they are added to the blockchain.

Anonymity: the real identity of each user is kept secret since each user interacts with a blockchain with a generated address.

Auditability: when a transaction is recorded in the blockchain the state of unspent transaction will change from unspent to spent. The transaction can be verified and tracked in a log.

14

2.3.3 Structure Transactions are validated by all the nodes in the network then these transactions are recorded in the block. As shown in Figure 2.3, a blockchain consists of a continuous sequence of blocks.

Fig. 2.3 Example of blockchain. From Zheng, Xie, Dai, Chen, Wang, 2017, p. 558.

Fig. 2.4 Block structure. From Zheng, Xie, Dai, Chen, Wang, 2017, p. 558. A block consists of a header and body as shown in Figure 2.4. A block header consists of the following elements:

● Block version: sets the validation rules

root hash: the hash value of all the transactions ● Timestamp: current time ● nBits: target threshold of a valid block hash

15

● Nonce: an 4-byte field, which usually starts with 0 and increases for every hash calculation ● Parent block hash: a 256-bit hash value that points to previous block

The block body “is composed of a transaction counter and transactions. The maximum number of transactions that a block can contain depends on the block size and the size of each transaction” (Zheng, Xie, Dai, Chen, Wang, 2017, p. 558).

2.3.4 Cryptography

Blockchain uses asymmetric cryptography to validate the authentication of transactions (Nomura Research Institute, 2016). “Digital signature based on asymmetric cryptography is used in an untrustworthy environment” (Zheng, Xie, Dai, Chen, Wang, 2017, p. 558). In the following we will look at the basics of asymmetric cryptography and digital signatures.

2.3.4.1 Asymmetric cryptography Asymmetric cryptography is also called public-key cryptography. It uses two separate keys in contrast to symmetric encryption where only one key is used. A public-key encryption scheme has six elements as shown in Figure 2.5.:

Fig. 2.5 Encryption with public key. From Stallings, Brown, 2018, p. 69.

16

In this scenario, both Alice and Bob generate a pair of keys which will hold a private key and a corresponding public key. These pairs of keys can be used to encrypt and decrypt messages. Both Alice and Bon put their public key either in a register or file that are publicly available. The corresponding private keys are kept private. The figure shows that each person already has a collections of public keys that were previously collected. If Bob wants to send a plaintext message which is represented with X to Alice Bob will will use an encryption algorithm together with Alice’s public key and the plaintext as an input. The formula Y = E[PUa, X] consists of the following elements: ● Y represents the ciphertext which is the scrambled message that is made as an output of the encryption algorithm ● E[...] represents the encryption algorithm which takes input(s) ● PUa represents Alice’s public key ● X represents the plaintext message So in simple terms, we create the ciphertext by using an encryption algorithm which will take the original and human-readable plaintext message and the public key of the receiver. Then the output that was produced which is the ciphertext will be sent to the receiver. When Alice gets the ciphertext she will decrypt it by using the corresponding private key. It is only Alice who can decrypt the message since it is only Alice who has the corresponding private key. The formula X = D[PRa, Y] consists of the following elements: ● X represents the original plaintext and human-readable message ● D[...] represents the decryption algorithm which takes input(s) ● PRa represents Alice’s private key ● Y represents the ciphertext which is the scrambled message that is made as an output of the encryption algorithm

17

2.3.4.2 Digital signature Asymmetric encryption can be used for authentication with the help of digital signatures (Stallings, Brown, 2018). Figure 2.6 shows the generic process of making and using digital signatures:

Fig. 2.6 Simplified Depiction of Essential Elements of Digital Signature Process. From Stallings, Brown, 2018, p. 73.

In this scenario, Bob wants to send a message to Alice. Bob will use a hash function which is represented by h in the figure to generate a hash value for the message. A digital signature generating algorithm will take the hash value and Bob’s private key to create a digital signature that is represented by S in the figure. This digital signature is attached to the original message then they are sent to Alice. When Alice gets the message with signature first she will calculate the hash value for the message then gives the generated hash value and Bob’s public key as inputs to a digital signature validation algorithm. If the algorithm shows that the signature is valid Alice can be sure that the message was signed by Bob.

18

2.4 Taxonomy of blockchain There are generally speaking three types of blockchain systems according to the nature of data accessibility: public blockchain, consortium blockchain and private blockchain (Lin, Liao, 2017).

2.4.1 Public blockchain It is an open source and permissionless system which means every individual has access thus can participate and approve transactions. The advantage is that there is “no need to maintain servers or system admins radically reduces the costs of creating and running decentralized applications” (Voshmgir, Kalinov, 2017). Bitcoin is an example for a public and open source blockchain. In a permissionless blockchain participants can stay anonymous and in the case of Bitcoin pseudonym can be used. Permissionless blockchains such as Bitcoin have problems regarding scalability and performance which are yet to be solved.

2.4.2 Consortium blockchain The consortium blockchain that is also known as federated blockchain functions as a closed group thus not every person take part. Only selected participants can verify transactions and the access to read entries on the blockchain can be restricted (Voshmgir, Kalinov, 2017). “One might imagine a consortium of 15 financial institutions, each of which operates a node and of which 10 must sign every block in order for the block to be valid” (Voshmgir, Kalinov, 2017). Federated blockchains tend to be faster than public blockchains which results in the lower amount of transparency for transactions.

2.4.3 Private blockchain A private blockchain is owned by an individual or by a group of individuals such as an organization. An invitation is needed if someone wants to join the network and it is also required that the new participants need to be validated (Voshmgir, Kalinov, 2017). Permissions to write are centralized meanwhile read permissions can be public or restricted. Interestingly the system becomes centralized since groups and participants are set up internally.

2.4.4 Comparison of types of blockchains The consensus mechanism is part of the table and will be explained in detail in a later chapter. But it is important to have a generic understanding of the term therefore I will introduce a rather basic description now and we will look at the concept in detail in a later chapter. So in simple terms a consensus mechanism is the way in which a majority of

19 network members agree on the value of a piece of data or a proposed transaction, which then updates the ledger. Public blockchain Consortium blockchain Private blockchain

Participants Permissionless: Permissioned: Permissioned: - Anonymous - Identified - Identified - Can be malicious - Trusted - Trusted

Consensus Proof of Work, Proof of Voting or multi-party Voting or multi-party mechanism Stake etc. consensus algorithm: consensus algorithm: - High energy - Light, fast - Light, fast consumption - Low energy - Low energy - 51% attack consumption consumption

Transaction Long Short Short approval Bitcoin: 10min or more 100xmsec 100xmsec frequency

Selling premise Disruptive Cost cutting Cost cutting - No middle man - Can reduce - Can reduce needed transaction costs transaction costs - Less data - Less data redundancy redundancy - High transaction - High transaction times times - More - More transparency transparency

Table I.: Overview of different types of blockchains. From Voshmgir, Kalinov, 2017

2.5 Distributed system If we want to understand blockchain first we need to understand decentralized distributed systems since at its core blockchain is indeed a decentralized distributed system. In the following we will look clarify these terms. The network is decentralized which means that the data is stored across its peer-to-peer network. It removes risks that come with data being held from one center namely having a central point of failure. Every node in a decentralized system has a copy of the entire blockchain and data quality is maintained by database replication and computational trust (Raval, 2016). Figure 2.5 shows visual representation of the three types of networks, namely centralized, decentralized and distributed.

20

Fig. 2.5 (a) Centralized. (b) Decentralized. (c) Distributed networks. From Baran, 1964, p. 1.

Most of the internet application that we are using today are centralized. They are owned by a person or by a group of people who have access to the source code and therefore can make changes. All the user data is on a centrally owned database that is owned and controlled by a company. It is necessary to fully trust the company. Decentralized means no node is instructing any other node as to what to do. The code runs on a peer-to-peer network of nodes and no single node has control. Bitcoin uses a blockchain decentralized ledger of transactions. Applications in which computation is distributed across components, communicate and coordinate their actions by passing messages. The components interact with each other in order to achieve a common goal. What we mean by saying distributed systems is having two or more nodes which are trying to reach a common goal in coordination. A node can be thought of as an individual user in the system. Every node possesses the capability to send and receive information to and from each other. Even though nodes are considered to be trustworthy but there are some that can be faulty or what is worse malicious by nature. A node that has malicious intentions is also called a Byzantine node. But the term can have another and more general definition which would imply that any behaviour that is unexpected of a particular node on the network is considered as Byzantine. So the distributed system needs to be capable of coping with nodes that become faulty or with network links that break in such a manner that makes it possible for the system to continue to work flawlessly. The matter of the fact is that designing distributed systems are quite challenging. In order to overcome issues a lot of research has been made over

21 the years which resulted in various solutions such as algorithms and mechanisms. Even though a lot of efforts were put into addressing the issues related to distributed systems a theorem has proved that a distributed system can not have all the properties that would be expected at the same time. The theorem is also known as the CAP theorem.

2.5.1 CAP theorem The CAP theorem, also called Brewer’s theorem after computer scientist Eric Brewer states that it is not possible for a distributed data store to simultaneously provide more than two out of the following three guarantees and that one has to choose between Consistency or Availability in case Partition is at present:

● C: Consistency: which means that every node on the network has the same, most recent value at a given time

Fig. 2.6 Consistency. From Leussink, 2018.

● A: Availability: which means that every request will get a response. But there is no guarantee that the data is the most recent.

Fig. 2.7 Availability. From Leussink, 2018.

22

● P: Partition tolerance: which means that the network continues to work even if a given amount of nodes have failed.

Fig. 2.8 Partition tolerance. From Leussink, 2018.

Availability over Consistency (A + P)

Fig. 2.9 Availability over Consistency. From Leussink, 2018.

As shown in Figure 2.9, if we choose Availability over Consistency a distributed system will be available but most of the times the data will be out of date.

23

Consistency over Availability (C+P)

Fig. 2.10 Availability over Consistency. From Leussink, 2018.

As shown in Figure 2.10, if we choose Consistency over Availability a distributed system will be accurate but most of the times it will not be available. In blockchains Consistency is not achieved simultaneously with Partition tolerance and Availability but over a period of time and it is called eventual consistency (Bashir, 2017). For this goal mining was introduced in Bitcoin. Mining is a process where the participants reach a consensus via a consensus algorithm which is Proof of Work in the case of Bitcoin.

24

2.5.2 Byzantine Generals problem One of the biggest problems of distributed computing systems is Byzantine generals problem. The term comes from the allegory, Byzantine Generals Problem. The goal of the allegory was describe a situation in which a catastrophic failure of a system should be avoided but the problem is that the actors need to agree on one strategy meanwhile some of these actors can not be trusted which would result in the failure of the whole operation. Now let us take the allegory a bit further and imagine that we have all the Byzantine generals who would like to attack a city. The problem is that there is a big distance between the generals and their armies so it is complicated to communicate with them thus it is also not possible to make a coordinated move. Even more, one general could be a traitor and sending contradicting information, as shown in Figure 2.11:

Fig. 2.11 The general is a traitor. From Lamport et al., 2002, p. 385.

25

The other problem is that they need to work together and attack the city at the same time otherwise they lose the battle. One obvious solution is to send a messenger who would spread the correct message across all the generals. But our solution which was the messenger in this case becomes the weak link in our situation since the messenger can be captured and killed or replaced with another messenger from the city. It will lead to loss of information or spreading tampered information across, as shown in Figure 2.12.

Fig. 2.12 Lieutenant 2 is a traitor. From Lamport et al., 2002, p. 385.

The problem was solved by the Practical Byzantine Fault Tolerance algorithm (Castro, Liskov, 1999). The first practical implementation came in 2009 when Bitcoin introduced the Proof of Work algorithm which was a mechanism to achieve consensus.

2.6 Consensus algorithms Since a blockchain is a decentralized peer-to-peer system it has no central authority who would make the final decision. The advantage is that it avoids corruption that would come from a single source. On the other hand it creates other problems: ● How are decisions made? ● How to get anything done? Let us imagine how these questions would be answered in case a system that is centralized. In case of a centralized organization all the decisions are made by a selected

26 board. But in the blockchain it is not feasible since there is no such concept as a leader. In order to make decisions a consensus needs to be reached. Mechanisms are made so that such a consensus could be reached. A consensus is practically a method for reaching an agreement within the individuals of a group. The goal of the consensus is not just to settle according to a majority rule but to make sure that the agreement that is reached would benefit the group as a whole. The method that is used in the decision making process is called a consensus mechanism. But what do we really want to achieve with a consensus mechanism? The goals are: ● Agreement: to achieve a high level of agreement from the group as possible ● Collaboration: all members should work together in order to reach a result considering the best interest of group ● Cooperation: all individual members should work together as a team where no one is more important ● Egalitarian: all members have one vote and every vote has the same weight ● Inclusion: in the consensus process as many members as possible should take part ● Participation: all members should actively take part in the whole process

In the following we will look at two of the most common approaches to reach a consensus, namely Proof of Work and Proof of Consensus.

2.6.1 Proof of Work (PoW) The Proof of Work is used in Bitcoin. A lot of work needs to be done if a node wants to publish a block of transactions. What we mean by work here is calculations done by computers. With Proof of Work every participant on the network is calculating the hash value of the blockheader. The consensus is only valid if the calculated value is equal to or smaller than a given value. If one node gets the target value the other nodes on the network need to mutually confirm if the calculated hash value is correct. If the block is valid other miners will add to their own blockchain. A miner is a node that calculate hash values and mining is the Proof of Work procedure in Bitcoin.

27

It is theoretically possible that more than one valid block would be created at the same time and in this case different branches would be made as shown in Figure 2.13.:

Fig. 2.13 Block structure. From Zheng et al., 2017, p. 560.

In case of Proof of Work protocol the longer chain becomes the genuine one. A lot of resources are wasted since in the Proof-of-Work protocol miners have to do a lot of calculations that use an enormous amount of computing power. The disadvantages of this approach are the following: ● It is not an efficient process and it uses a lot of power and energy ● Individuals, groups and organizations that can afford powerful and expensive ASIC (Application Specific Integrated Circuit) have an advantage with mining.

28

If we look at the hashrate distribution the diagram makes it clear that there are 5 mining pools that have around 80% of the hashrate, as shown in Figure 2.14. So in theory these pools could make a group and make a 51% attack on the bitcoin network.

Fig. 2.14 Hashrate distribution. From Blockchain Luxembourg S.A.

2.6.2 Proof of Stake (PoS) The proof of stake algorithm deals with the drawbacks of the proof of work algorithm. It is a new concept where every individual can mine or even validate new blocks only based on their coin possession. The miners get previously chosen and the process is random but not every minor can participate. If you have an amount of coins in your wallet then you are considered as a node on the network. If you want to be a miner you need to do an extra step namely to put an amount of coins in deposit. After the validators will be chosen in a voting system and the miners will stake a minimum amount that is required. New blocks are created proportionally to the number of coins in the wallet. So if you own 20% of all the coins then you get to mine 20% new blocks. There are different ways to take part in the staking. You can loan your coin to another user then share the profit but you need a reliable person to do so. Another way is to join the pool. So the profit will be divided based upon the number of participants and on the amount that was put on stake.

29

The biggest advantage is the significantly lower energy consumption. You also do not need sophisticated hardware but a computer system with a stable internet connection. Here the fact of owning coins will be enough to validate transactions. Even though it reduces the threat of a 51% attack the full decentralization is not possible. Also, “The selection based on account balance is quite unfair because the single richest person is bound to be dominant in the network” (Zheng et al.,2017). Platform that uses PoS is e.g. Peercoin1.

2.6.3 Comparison of consensus algorithms

Property PoW PoS

Node identity management open open

Energy saving no partial

Tolerated power of < 25% < 51% adversary Computing power Stake Table II. Typical Consensus Algorithms Comparison. From Zheng et al., 2017, p. 560.

As Table II. shows, PoW, PoS can join the network without identification. The energy consumption in PoW is on a huge scale. Miners in PoS still have to hash the block header but the amount of work that needs to be done is reduced. In order to gain control of the whole network 51% of the hash power is needed. But in PoW due to selfish mining it is possible to reach the same goal with 25% (Eyal, Sirer, 2014).

2.7 Uses cases and applications Companies are trying to find new ways for the practical use of blockchain technology. The following list provides a few examples for applications (Zīle, Strazdiņa, 2018): ● Exchange of value ● Internet of Things (IoT) ● Decentralized markets ● Supply chain management

2.7.1 Exchange of value The major influence of the blockchain technology is the exchange of value via peer-to- peer network (Zīle, Strazdiņa, 2018). Since the intermediaries are eliminated cross border payments became much cheaper. The global financial system that we use on a daily basis rely on outdated systems and it has various problems such as high transfer cost,

1 Pioneer of Proof of Stake. [Online]. Available at https://www.peercoin.net

30 limited ways to deal with money etc. Companies such as Ripple2 are working on financial technologies that are built with blockchain technology.

2.7.2 Internet of Things (IoT) IBM and Samsung are working on ADEPT which is a blockchain based technology that could form the base of a decentralized network of IoT applications (IBM Global Business Services, 2014). Blockchain would be a public ledger for the billions of interconnected devices that would not need a central hub for communication.

2.7.3 Decentralized markets Due to the decentralized nature of blockchain markets based on blockchains could ensure for people in different parts of the world to trade with each other without depending on a third party. Slock.it3 is a startup that is working on such a decentralized market platform.

2.7.4 Supply chain management Supply chain is a system where organizations, activities, information, resources and people are involved in the act of transferring a service or a product from suppliers to customers. The transactions can be documented in a permanent decentralized record with blockchain. The advantages are that it reduces added costs, added costs and errors. Skuchain4 is a good example for this use case.

2 Ripple. Global Payments. [Online]. Available at https://ripple.com 3 Slock.it A Blockchain Company. [Online]. Available at https://slock.it 4 Skuchain: Empower my supply chain [Online] Available at https://www.skuchain.com

31

Part III - Prototype

3. Prototype - Blockchain and Decentralized Application (DApp)

3.1 Introduction The goal of this part is to put the theoretical knowledge we gained in the previous section into practice. We will look at two pilot projects that were developed to demonstrate some of the functionalities of Blockchain and Decentralized Application. The additional goal of the Decentralized Applications is to get a better understanding of smart contracts regarding Ethereum and their practical use in applications. The code and concepts will be explained on the way. Please note that due to certain limitations the full source code will not be present here. Code snippets that will be shown serve a purpose for proving or demonstrating a concept. Other source code will be available in the Appendices: Appendix B will contain the full source code for the Blockchain proof of concept project. The full source code for projects are available at the following Github account: https://github.com/Hunor85/blockchain-prototype

3.2 Blockchain - proof of concept

3.2.1 Block class In the main.js file we create a Block class with a constructor. in order to create a new block you need to pass a timestamp, data, hash of the previous block: class Block{ constructor(timestamp, data, previousHash = '') { this.previousHash = previousHash; this.timestamp = timestamp; this.data = data; } }

32

Description of the properties: ● timestamp: it tells us when the block was made ● data: it can include any type of data. In case of cryptocurrency we can store details about the transaction such as the amount of money that was transferred or the sender or the receiver ● previousHash: it contains the hash of the previous block

3.2.2 Hashes Each block has a hash that points to a previous block. A hash is basically a unique fingerprint. We can calculate the hash by taking all the contents from the block and run it through a hash function. Inside the Block class we create a calculateHash function: calculateHash() { return SHA256(this.previousHash + this.timestamp + JSON.stringify(this.data)).toString(); }

We are going to use the SHA256 hash function which needs to be installed through an external library.

The calculateHash() method can now be used in the Block constructor: class Block{ constructor(timestamp, data, previousHash = '') { this.previousHash = previousHash;

this.timestamp = timestamp; this.data = data;

// When creating a new Block, automatically calculate its hash. this.hash = this.calculateHash(); } }

33

3.2.3 Blockchain class After declaring the Block class the next step is to define the Blockchain class. The Blockchain class will look like this: class Blockchain{ constructor() { this.chain = []; } }

The Blockchain is a simple object that contains an empty property of type array called chain. The first Block called on the Blockchain is the genesis block. In order to create this genesis block we add the following createGenesisBlock() method: createGenesisBlock() return new Block("01/01/2000", "Genesis block", "0"); }

In the Blockchain class constructor we can add the genesis block: class Blockchain{ constructor() { this.chain = [this.createGenesisBlock()]; }

3.2.4 Additional methods The getLatestBlock() method will return the last element in the chain array: getLatestBlock(){ return this.chain[this.chain.length - 1]; } In the addBlock() method when we add a new Block to the chain we need to correctly set the previousHash property. We have to calculate the hash of the new Block: addBlock(newBlock){ // The new block needs to point to the hash of the latest block newBlock.previousHash = this.getLatestBlock().hash; // Calculate the hash of the new block newBlock.hash = newBlock.calculateHash(); // Now the block is ready and can be added to chain! this.chain.push(newBlock); }

34

3.2.5 Validation In order to verify the integrity of the Blockchain we need to create a isChainValid() method: isChainValid(){ for (let i = 1; i < this.chain.length; i++){ const currentBlock = this.chain[i]; const previousBlock = this.chain[i - 1];}

// Recalculate the hash of the block and see if it matches up. // This allows us to detect changes to a single block if (currentBlock.hash !== currentBlock.calculateHash()) { return false; } // Check if this block actually points to the previous block (hash) if (currentBlock.previousHash !== previousBlock.hash) { return false; } } // Check the genesis block if(this.chain[0] !== this.createGenesisBlock()){ return false; } // If we managed to get here, the chain is valid! return true; }

We need to loop over the whole chain in order to verify integrity. Inside the loop we need to check the following: ● The first is to check if the hash of the current Block is valid? We can do that by recalculating the hash for every Block and check if any change was made ● The second is to check if each block points back to the correct previous Block. We can do that by checking the previousHash property of the block is equal to the hash property of the Block before it ● And finally we check if the genesis block is indeed unchanged

3.2.5 Mining Up until this point it is possible to do malicious actions with our Blockchain. It is possible to change the content of a Block and recalculate the has for all the coming Blocks. In order to solve this problem a Proof of Work mechanism was invented to avoid such

35 problems. The main idea is to make it more complicated to add a new Block and prove that we put a lot of effort or in case of a computer a lot of computing power to create and add a new Block. This whole process is called mining. In case of the Proof of Work the hash of a block needs to start with a certain amount of zeros. The amount of zeros required is also called the level of difficulty which in practice will also determine how many Blocks will be created. We can reach it by adding a nonce value to the block. A nonce is a random value that will change the hash until it fulfils the given requirements. First we add the nonce to our Block class: class Block{ constructor(timestamp, data, previousHash = '') { this.previousHash = previousHash; this.timestamp = timestamp; this.data = data; this.hash = this.calculateHash(); this.nonce = 0; }

Next we create the mineBlock() method which will take the difficulty level as a parameter and will keep running until the generated hash will have the amount of zeros that are required: mineBlock(difficulty) { // Keep changing the nonce until hash of block starts with enough zero's. while (this.hash.substring(0, difficulty) !== Array(difficulty + 1).join("0")) { this.nonce++; this.hash = this.calculateHash(); }

console.log("BLOCK MINED: " + this.hash); }

The loop will until the hash starts with the necessary amount of zeros and difficulty will define the number of zeros that are required. For every failed attempt the value of nonce will be increased by 1 when the hash is calculated so we need to alter the calculateHash() method: calculateHash() { return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data) + this.nonce).toString(); }

36

In our Blockchain class we set the difficulty level to 3 for example: constructor() { this.chain = [this.createGenesisBlock()]; this.difficulty = 3; }

Then we alter the addBlock() method so mining will actually happen: addBlock(newBlock) { newBlock.previousHash = this.getLatestBlock().hash; newBlock.mineBlock(this.difficulty); this.chain.push(newBlock); }

After all the changes let us run our Blockchain with the newly implemented Proof of Work algorithm in place: let hunorChain = new BlockChain(); console.log('Mining block 1...'); hunorChain.addBlock(new Block(1, "20/07/2019", { amount: 4 }));

console.log('Mining block 2...'); hunorChain.addBlock(new Block(2, "20/07/2019", { amount: 8 }));

When we run our code we see the following result in our terminal: Hunors-MBP:blockchain-app-proof-of-work node main Mining block 1... BLOCK MINED: 000ecf448ef0f4192ac11f4aad8fbe77ce3b64647b79a848d06430345de919ff Mining block 2... BLOCK MINED: 0006685e562443d074d78239538eff1d9aa933147ed858b0dfcc4140210db268 As we set the difficulty level at 3 it means that the first three digits of the created hash values must be 0. If we experiment with the difficulty level and we increase it to 5 for example we significantly see that the mining process will take longer.

3.3 Decentralized Application - proof of concept In the following we will create a todo list Decentralized Application (also known as DApp) since it is a sufficient way to look at how to read and write data from the Blockchain and

37 learn about the differences between a traditional web application and a blockchain based application. Along the way we will learn about the following topics: - Decentralized Application (DApp) - Ethereum - Traditional vs Blockchain based Web App

3.3.1 Decentralized applications A decentralized application is like a modern web application since it consists of a user interface and backend services that take care of the processing and complex logic. The backend services will use the Ethereum platform and especially the smart contracts that are deployed to it. The decentralized applications are built on the Ethereum blockchain network. They can serve different purposes even though they are on the same Ethereum network. Ethereum will be covered later. Figure 3.1 shows a high level understanding of how applications would work:

Fig. 3.1 Multiple decentralized applications on one Ethereum platform. From Singhal et al., 2018, p. 221.

38

With Ethereum it is possible to make not just money transactions but lands, vehicles, digital content and others that have value. Ethereum took another design approach then Bitcoin. It built an abstraction layer which made it possible that code from different applications could run on all the nodes.

3.3.2 Ethereum In simple terms, Ethereum5 is an open software platform based on blockchain technology that enables developers to build and deploy decentralized applications. Ethereum was developed by Vitalik Buterin in 2013. The main idea was to create a language which makes it possible to develop arbitrary programs for blockchain. Bitcoin for example is very limited and only allows basic operations. The first release of Ethereum was called Frontier. The final release is called serenity and it is an interesting one since it investigated how to make significant changes. These are changes like moving from Proof of Work to Proof of Stake, scalability and privacy. But the development will not stop here since the development team continues to invest time and effort into further changes. But the proposal of web 3.0 seems to be a real deal breaker. The idea of web 3.0 is to create an intelligent system where all major services such as DNS and search engines would be decentralized and Ethereum would be there to make this come true.

3.3.3 Traditional vs Blockchain based Web App First let’s look at how it would look like as a web application. We would communicate through a web server to access the todo application. The code and all the data for the application would be on a server as shown in Figure 3.2:

Fig. 3.2 Traditional Web Application Architecture. Author own illustration.

5 Ethereum - Ethereum is a global, open-source platform for decentralized applications. [Online] Available at https://ethereum.org

39

Even though software architecture has gone through a lot of advancements the most common architecture is the so called three tier architecture which are the presentation tier, logic tier and data tier. The three tier architecture is represented on Figure 3.2.

The presentation tier is the top most level of the application and also referred to as user interface. The main responsibility of the user interface is to translate tasks, results so it is human readable. The logic tier coordinates the application. It will make all the logical decisions, evaluations and performs all the calculations. This tier also moves data between the two surrounding tiers. Regarding the data tier information is stored and retrieved from a database or file system then eventually it passed back to the user.

A Blockchain based application is similar to web apps but there are certain differences as shown in Figure 3.3.:

Fig. 3.3 Blockchain based application. Author own illustration.

The presentation tier uses the same technologies to render a page, namely HTML, CSS, JavaScript. The biggest difference is that they do not use an API to connect to a database but they use a smart contract to connect to the Blockchain.

The smart contract is in the logic tier. By now we can think of a smart contract as a normal business contract written in code where two or more actors come into an agreement when certain conditions are fulfilled. In the next section we examine smart contracts deeper.

The data tier is where the Blockchain and just like a database it stores data and records transactions. The big difference compared to a traditional database is that while a database is on one server the Blockchain is distributed along the nodes that participate on the network.

3.3.4 Smart Contract Here we will look at smart contracts. After looking at its short history and coming up with a definition then we will look at Ethereum smart contracts.

40

Smart contracts are self executing contracts. They contain the terms of the agreement between the buyer and the seller. These terms are written into code. Smart contracts were first proposed by Nick Szabo who is an American computer scientist. He created a virtual currency called Bit Gold in 1998 which was 10 years before the invention of Bitcoin. The original idea of Szabo was to extend the functionality of electronic transaction methods to the digital area. He suggested smart contracts for derivatives and bonds. Szabo wrote: "A smart contract is a computerized transaction protocol that executes the terms of a contract. The general objectives of smart contract design are to satisfy common contractual conditions (such as payment terms, liens, confidentiality, and even enforcement), minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries. Related economic goals include lowering fraud loss, arbitration and enforcement costs, and other transaction costs" (Szabo, 1994). Also: "These new securities are formed by combining securities (such as bonds) and derivatives (options and futures) in a wide variety of ways. Very complex term structures for payments can now be built into standardized contracts and traded with low transaction costs, due to computerized analysis of these complex term structures " (Szabo, 1994). So in simple terms it means the sale and purchase of derivatives with very complex terms. In today's world this is done by the use of computer networks that use complex term structures. Unfortunately, there is no consensus on a common definition for smart contracts. But we will create a definition that we will use later on. A smart contract is a computer program that has the following characteristics: - Executes automatically - Enforceable - Semantically valid - Secure and unstoppable Smart contracts are enforceable, which means that all the terms are executed as defined and expected. The key idea is that the written code is the law which means that there is no need for a third party. Smart contracts are secure and unstoppable which means that they should execute and maintain a functioning internal state. They use a state machine model which manages the internal state. Smart contracts are automatically executable but there are suggestions that automatable would be a better option because in certain situations a manual input is necessary. Smart contracts are deterministic by nature. It makes sure that a smart contract will achieve the same result in every node. Furthermore this characteristics ensures integrity and stability. So our definition for smart contracts would be that:

41 a smart contract is a secure computer program that represents a digital agreement between the two parties. It is automatically executed when certain conditions are met. Due to this feature it is enforceable and unstoppable once executed.

On the Ethereum Blockchain smart contracts can express conditions and business logic for complex programmable transactions. Developers can use programming language like Solidity to make smart contracts. The Ethereum Virtual Machine (EVM) will run the low- level bytecode language that Solidity is compiled in every node on the Ethereum network.

Fig. 3.4 Ethereum smart contract. From Xu t al., 2019, p. 38.

According to Figure 3.4 the following takes place: ● A contract creation transaction deploys the smart contract ● The transaction contains the code of the smart contract ● The transaction sender will authorize the transaction with its signature ● When the transaction for creating the smart contract is successful the smart contract will get a contract address - which will serve as an identifier An Ethereum smart contract account contains the following: ● Executable code ● Internal state storage ● Contract balance containing an amount of Ether After deployment users can send Ether to smart contract by monetary transaction. Functions of the smart contract can be invoked by sending so called contract-invoking transactions. These contract invoking transactions will contina the following: ● Interface and parameters of function ● The amount of Ether that would be paid for the execution

42

3.3.5 DApp development

3.3.5.1 Architecture The architecture of the Decentralized Application will look as shown in Figure 3.5.:

Fig. 3.5 Architecture of Decentralized Application. From Author’s own illustration

3.3.5.2 Dependency installation We start the DApp development with installing the dependencies we need. We will start with installing Ganache6. Ganache is a personal Blockchain for a local development that we can use to mimic the behaviour of a public blockchain. It will allow us to deploy smart contracts, develop applications.

6 Ganache - a personal Ethereum blockchain which you can use to run tests, execute commands, and inspect state while controlling how the chain operates. [Online] Available at https://www.trufflesuite.com/ganache

43

When running Ganache we practically have our personal Blockchain network with a list of accounts that are connected to the network:

Every account has 100 Ether. Ether acts as a form of payment for the network participants to execute their operations on the network. It makes the development easier. If we wanted to create our personal Blockchain network from scratch we would need to create these accounts manually and credit them with an amount of Ether.

The next dependency is the Truffle Framework7 which gives us tools to develop smart contracts with the Solidity8 programming language. Some of the functionalities of the Truffle Framework that will make developing smart contracts efficient are:

● Smart Contract Management - write smart contracts with the Solidity programming language and compile them down to bytecode that be run on the Ethereum Virtual Machine9 (EVM). ● Deployment & Migrations - write scripts to migrate and deploy smart contracts to any public Ethereum blockchain network.

7 Truffle - A world class development environment, testing framework and asset pipeline for blockchains using the Ethereum Virtual Machine (EVM), aiming to make life as a developer easier.[Online] Available at https://www.trufflesuite.com 8 Solidity - Solidity is an object-oriented, high-level language for implementing smart contracts. Solidity is statically typed, supports inheritance, libraries and complex user-defined types. [Online] Available at https://solidity.readthedocs.io/en/v0.6.0/ 9 Ethereum Virtual Machine - The Ethereum Virtual Machine (EVM) is a powerful, sandboxed virtual stack embedded within each full Ethereum node, responsible for executing contract bytecode. Contracts are typically written in higher level languages, like Solidity, then compiled to EVM bytecode. [Online] Available at https://www.bitrates.com/guides/ethereum/what-is-the-unstoppable-world-computer

44

● Network Management - connect to any public Ethereum blockchain network, as well as any personal blockchain network you might use for development purposes. ● Script Runner - write custom scripts that can run against a public blockchain network with JavaScript. You can write any arbitrary code inside this file and run it within your project. ● Client Side Development - configure your truffle project to host client side applications that talk to your smart contracts deployed to the blockchain.

Finally we need to get the MetaMask10 extension for Google Chrome. Unfortunately major browsers do not connect to Blockchain networks so we need to install this extension and another disadvantage that such an extension only exists for Google Chrome by now.

After installing the extension we will be able to manage our personal account when we connect to the Blockchain and also manage our Ether funds that we need to pay for our transactions.

3.3.5.3 Development First we initialize a new truffle project and the project directory will look as the following:

Let’s look at the structure in more detail: ● contracts directory: it will all our contracts. By default we got a Migration contract that takes care of our migrations to the Blockchain network. ● migrations directory: we can think of migrations being similar to web development frameworks that require migrations to change the state of the database. ● node_modules directory: this directory will contain all the node dependencies

10 MetaMask - MetaMask is a bridge that allows you to visit the distributed web of tomorrow in your browser today. It allows you to run Ethereum dApps right in your browser without running a full Ethereum node. [Online] Available at https://metamask.io

45

● test directory: as the name suggests we can write tests for our smart contracts ● truffle-config.js: it is the main configuration file for the project

We create our smart contract called TodoList and add a state variable called taskCount which will track the number of tasks: pragma solidity ^0.5.0;

contract TodoList { uint taskCount; } Next, we compile our smart contract and a new file called TodoList.json is generated. This file is the ABI file which stands for Abstract Binary Interface which has the following responsibilities: ● It contains the bytecode version of the smart contract ● It contains the JSON representation of the smart contract functions In order to connect to Ganache we need to make the following configurations in our truffle-config.js file: module.exports = { networks: { development: { host: "127.0.0.1", port: 7545, network_id: "*" // Match any network id } }, solc: { optimizer: { enabled: true, runs: 200 } } }

46

These should match the default settings provided by the Ganache personal blockchain network:

In order to list the tasks we need a way to model a task. Solidity allows us to define your own data types with structs. We use a struct to model the task like this: contract TodoList { uint public taskCount = 0;

struct Task { uint id; string content; bool completed; } }

The attributes of the Task struct: ● The id of type uint is the unique identifier. By uint we mean that it is a non-negative integer. ● The content of type string is the text of the task ● The completed of type bool which will define whether a task is completed or not By putting the tasks into mapping we create a key-value pair that is stored on the Blockchain network. Mapping is a special data structure and tasks become a state variable. contract TodoList { uint public taskCount = 0; struct Task { uint id; string content; bool completed; } mapping(uint => Task) public tasks; function createTask(string memory _content) public { taskCount ++; tasks[taskCount] = Task(taskCount, _content, false); } }

47

In order to create function we made the public function createTask() which consists of the following elements: ● The function takes an argument called _content which will be the text of the task ● Each time a new task is created the taskCount property is incremented by 1 so we can track of them just like would do in case of a traditional database solution ● The struct is created by calling Task() with its parameters which are taskCount, _content and false

The project consists of other technologies such as web3.js as well but our focus was on to learn about smart contracts in Decentralized Application and how they could be utilized with Ethereum. In short web3.js “a collection of libraries which allow you to interact with a local or remote ethereum node, using a HTTP or IPC connection11”.

Before we look at how the application functions there is one concept we need to understand regarding Ethereum and it is the Gas system.

3.3.6 The Gas system Ethereum Gas is a unit. It measures the amount of computational effort that it will take to execute the operations. Thus every single operation requires some amount of gas. An amount in Ether will be paid to miners. Gas is used to calculate the amount of fees that need to be paid in the network.

Satoshi Nakamoto created bitcoin and we got a decentralized monetary system where we can transfer money to each other. Although, this first-generation Blockchains had a problem. The problem was that it only allowed us monetary transactions without any conditions that we could add. If Alice wants to send Bob 10 bitcoins she could not specify any conditions for the transaction. Also it would be extremely difficult to make such conditions in scripting. Smart contract was what solved this problem. Smart contracts can help us to exchange not just money but property, shares or anything with a value while we can avoid a middleman.

Vitalik Buterin, co-founder of Ethereum, proved the world what Blockchain can evolve to. On the Ethereum system smart contracts will get certain tasks done. They are a series of instructions that are written in a programming language called Solidity. We can imagine a vending machine where steps are executed in a sequential order and each step is a trigger for the next step to be executed. In case of the vending machine in the Ethereum network it would work like the following:

11 Web3.js - Ethereum JavaScript API [Online] Available at https://web3js.readthedocs.io/en/v1.2.4/

48

● First we give the vending machine money. This action will be recorded and then sent to all the participants on the network. In case of a change the ledger will get updated and the newly updated ledger will be broadcasted to every node on the network. ● Since our example is a vending machine we push the button to ask for the chosen item. The record of this action gets updated in the ledger. ● We get the chosen item and this gets recorded by all the nodes and the shared ledger.

So as we could see with our example every single transaction gets recorded and updated on the network.

As we stated earlier Gas is a unit that measures the amount of computational effort that it takes to execute operations. Every line of code that we write in Solidity requires an amount of gas. The Ethereum Yellowpaper (Wood, 2019) specifies how much given instructions cost regarding Gas as shown in Figure 3.6. The minimum amount of Gas is 21000.

Fig. 3.6 Ethereum Fee Schedule. From Wood, 2019, p. 25.

The Gas has two components which are limit and price. The functioning of the Ethereum is ensured by the following elements: ● Ether (ETH) is the native currency of the network. ● Gas is the unit of calculation that indicates the fee for an action or a transaction ● Gas limit is the maximum amount of Gas that a user is willing to pay for performing an action or a transaction ● Gas price is the amount of Gwei that the user is willing to pay per unit of Gas. A Gwei is worth 0.000000001 Ether

49

Let us look at an analogy that makes all these elements and their connections more clear. Gas is the amount of fuel that we need to get from point A to point B in a car. The further we need to go the more Gas we need. The Gas limit is the amount of fuel we need to put into the tank. The Gas price is the price we pay for each liter of fuel. The higher the cost of fuel per liter the faster the car will get us to the destination. Consequently, the lower we pay for the fuel the slower the car will take us to the destination.

But why does Ethereum use the Gas system? Ethereum is a Proof-of-Work peer-to-peer system and depends on the hashrate of the miners. It practically means that the more miners in the system the more hashrate overall which creates a stable and secure system. So the Gas system is really there to attract more miners. The miners can become temporary leaders of their mined blocks which means that the miners will use their computational power to validate smart contracts. For doing so they can charge a fee which makes the process profitable. A conversion does not have a fixed price. The sender of the transaction decides on his Gas price and the miners will verify the transaction they prefer. But it is not surprising that the miners will usually take the highest Gas price.

3.3.7 Walkthrough of prototype We launch the application and open in Google Chrome. As it was stated earlier we need to use MetaMask which is an extension but only available for Google Chrome.

After launching our simple application will look like the following.

50

MetaMask is connected to Ganache so we get access to free accounts with Ethers. Below the name Account 3 we can see a long number which is basically the address of a Ganache account:

Connecting Ganache with MetaMask happens by clicking at the key symbol then copying the private key into MetaMask:

Now let us create a task in our list. We simply type in the task then press Enter:

51

Straight after MetaMask will pop up and under the DETAILS section it will ask us to pay for the fee for the operation. If we click at the DATA section we can see that the function type we want to execute is about to create a task which is of type string:

52

If we decide to customize the Gas MetaMask will give us suggestions. The basic idea is that paying more results in less time and a higher chance to create the transaction. If we want to decide upon the Gas price and Gas limit by ourselves we can choose the Advanced options:

After saving and confirming our action a pop message will appear in our browser and tell us that our action was successful:

53

The transaction is recorded in the MetaMask History:

Also the transaction is recorded in Ganache:

54

Under the CONTRACT section we see the name TodoList which is the name of our application and to the right we see an ADDRESS field which is practically the address of our deployed smart contract:

55

Part IV - Theoretical background - Real estate 4. Theoretical background - Real estate management process

4.1 Introduction The aim of this part is to provide a theoretical background to the domain area namely real estate. This part will look at the following topics: ● Definition of real estate ● Real estate management process ● Stakeholders ● The acquisition process in real estate life cycle ● The operating process in real estate life cycle

4.2 Commercial real estate The commercial real estate market consists of the space market and the asset market (Geltner, Miller, 2001). The space market is the market for the use of real property. The asset market is connected to the ownership. The space market is very important since the rent for real estate creates the cashflow which determines the property value. Real estate, commodities and financial derivatives are examples of asset classes. An asset class is a group of investments that have similar characteristics and are subject to the same laws and regulations. In case of calling real estate asset class management as a corresponding term comes up. It can be property management, asset management or portfolio management as shown in Figure 4.1. Real estate management is the discipline to realize pre-defined investment objectives and systematically optimizing the returns of entrusted real estate assets by strategically managing and transact them in their total life cycle and value chain (Bosak, Mayer, Vogel, 2007).

56

Fig. 4.1 Real estate management process. Illustration based on Vrijhoef et al., 2014 p. 5.

The real estate management can be further divided into three phases which are acquisition, operation and disposition. In the acquisition phase the investor or asset manager will choose the portfolio product and buy the property. The actual management starts in the operational phase which as described earlier consists of three different levels which are portfolio management, asset management and property management. The main function of portfolio management is to realize the goals and objectives of the investor. The portfolio manager is responsible for reporting to the clients and manage the cash flow (Miles et al., 2007). The goal of the asset manager is to optimize the direct returns of the asset and to maximize the asset value. As a person the asset manager can be internal or external. The responsibilities are the following: developing strategic plans, choosing the right asset, monitoring property performance, assisting in tenant relations (Miles et al., 2007). Property management is about supporting the asset manager in the daily tasks. In summary the main areas of responsibility for a property manager is: tenant relations; collection rent; controlling operational expenses; maintenance of property; crisis management; public relations (Miles et al., 2007).

4.3 Stakeholders The real estate industry is fractured and consist of various parties. In the following we will look at the different stakeholders in the real estate industry.

57

We can distinguish between 8 stakeholders in the commercial real estate: ● Occupiers ● Government ● Investors ● Funders ● Contractors ● Designers ● Brokers ● Advisors

4.3.1 Occupiers The occupiers are the users of the building. They are the most important stakeholders in the operational phase. They can be divided into two groups such as tenants and owner- occupiers. The tenants are using the building meanwhile the owner-occupiers are the owners of the building.

4.3.2 Government The government plays an important role in case of regulations such as fiscal policies, law. It is responsible for organizing the registration process for properties in institutions such as land registry.

4.3.3 Investors Investors are the ones who have the property. There are two types of investors namely private and institutional. For investors buying and selling a property is an investment where cash flow is generated by the tenants.

4.3.4 Funders If necessary investors can include funders in the process. A funder will provide an amount of loan which fill finance the enterprise. If the investor is not able to pay the loan back the real estate asset will function as a security.

4.3.5 Contractors and Designers These two actors are responsible for the physical aspect. They have the knowledge about what materials and designs to use change or improve the existing building.

4.3.6 Brokers They bring demand and supply together. Brokers are responsible for obtaining new tenants and negotiating contracts with tenants.

58

4.3.7 Advisors The advisors support stakeholders where specialized knowledge is needed in areas such as finance, law.

4.4 The acquisition process in real estate life cycle The first step of the real estate management is the acquisition. According to McNamara (1998) this initial step can be divided into further phases: ● Preparation period ● Marketing period ● Due diligence period ● Exchange to completion

4.4.1 Preparation period The first task is to reduce the real estate portfolio then decide upon which property to sell. When the choice is made the necessary information is collected to provide a detailed overview of the asset. In this period a broker is selected who will assist in the next stages. The last step is to prepare an assessment of value and marketability.

4.4.2 Marketing period The agency produces brochures, advertisements etc. for potential buyers. The duration depends on factors such as location, size of the asset, real estate type (Hordijk, Teuben, 2008). At the end of this period the best bids are chosen and invited for a meeting.

4.4.3 Due diligence period This period consists of issues regarding real estate, law, taxation, accounting and technical issues (Bosak et al., 2007). It is a period that can lead to high costs. A buyer should get a clear proposal with a detailed summary of the necessary information.

4.4.4 Exchange to completion It is the precise date when the ownership is transferred. The contract needs ensure that the ownership rights and the cash are transferred accordingly.

4.4.5 Process flow The preparation period in general is needed for the buyer to get the necessary information about the property. A head of terms will be signed when this part of the process is successful. A head of terms is the point where the buyer could make further negotiations and the start for due diligence. The due diligence phase will provide some insights which

59 will be the base for the contract negotiating. If both parties agree on the contract contracts will be sent to each other. At this time both parties are committed to the deal and the documents are ready for completion in the phase of completion. An intensive research was made by IPF (2012) into describing the commercial property transaction process and made a flowchart of the process between seller and buyer. The following Table III. is based upon the result of the research of IPF. Seller Buyer

Heads of terms Instruct advisors M Instruct advisors A Consider sources of finance and R Review property information and time line to secure funding: devise strategy to deal with any debt/equity K issues E T Any restrictions/ limitations on I ability to sell: third party consents, N banking issues (ensure early consultation) G

Procure Energy Performance Certificate

Pre-contract D Consider carrying out searches: whilst Investigate title U traditionally carried out by the buyer, the provision of searches allows the Carry out surveys, prepare reports E seller greater control when setting the Negotiate contract time limit for exchange of contracts. D Searches may take 3 to 8 weeks depending on the location and nature I of the property L I Make available pre-contract legal package/access to data site G E Negotiate contract N C E Exchange contracts Pay deposit

C Seller now committed to the deal Buyer now committed to the deal O M Pre-completion P Seller continues to manage (in Pre-completion searches L accordance with contract) E Finalise mechanics for drawdown /

60

Preparation of completion statement transfer of completion monies T Prepare requisitions on title I O Completion N Discharge mortgage (Closing) Pay completion monies Buyer assumes responsibility

Post-completion Land Registry application Collation of deeds – data site

Table III.: Overview of the real estate transaction process. Based upon IPF, 2012, p. 5.

4.5 The operating process in real estate life cycle In this phase the asset manager will create the property strategy and analyze the performance of a property. The property manager takes care of the daily management of the property and adjusts the strategy accordingly. During the property management phase there are four different responsibility types for the property manager which are ● Commercial management ● Administrative management ● Technical management ● Promotional management

4.5.1 Commercial management Commercial management makes the base of the property manager and contains the goals of the property manager. The main responsibilities of the property manager are: ● Daily contact with tenants and offering support and advice if needed ● Coordinating daily tasks ● Internal contact with asset manager ● Maintaining contracts with new or potential tenants ● Account management ● Juridical and fiscal affairs

4.5.2 Technical management The goal is to maintain the high quality of the property. The technical management consists of responsibilities such as: ● Planning technical maintenance (e.g. doing inspections) ● Solving technical complaints from the tenants ● Checking the quality of the improvements made on property

61

● Reducing energy consumption

4.5.3 Administrative management The goal is to collect and process the information about the incoming and outgoing cash flow of the property. The main tasks are the following: ● Collecting payments ● Calculating service charges ● Collecting and archiving information ● Writing reports and providing them to tenants if asked for it

4.5.4 Promotional management The goal is to improve the market position of the asset. The main tasks are the following: ● Marketing of the property ● Hospitality management

62

Part V - Discussion

5. Discussion

5.1 Introduction The goal of this chapter is to look at the possible scenarios in which it would be possible to combine the blockchain technology with the real estate management process. The two phases we look at are the acquisition and the operating phase as these phases were introduced and described in previous chapter. This part will look at the following possible solutions: ● The acquisition process: ○ Digitalization through smart contract ○ Efficient financing mechanism ● The operating process: ○ Digital lease contract Besides this chapter will look at technical and non-technical challenges related the Blockchain technology.

5.2 The acquisition process

The real estate transaction process consists of four major stages; preparation, marketing, due diligence and exchange to completion. Hereby we will look at three opportunities in the real estate transaction process for exploring the possibilities for a blockchain based solution.

5.2.1 Digitalization through smart contract For real estate transactions, the best option is that the seller has collected as many information as possible according to IPF (2012). The more information the seller has the more efficient the whole process will be. We can think of this amount of information is a database. The various parties will check and validate this information by themselves without trusting a third party. There could be a solution that would be able to validate and transact the different information from different stakeholders without the administrative action of a designated third party. Such a solution could be through a smart contract which is basically a self executing contract written in code and only executes if certain conditions are fulfilled. According to Karamitsos et al. (2018) there could the following steps in a real estate smart contract process: ● Rent contract signature process

63

● Rental payment process ● Termination rent contract process

As for now we are concerned with the preparation phase of the real estate management process where information is collected, exchanged and validated we will only focus on the first process which is concerned with these steps. The rent contract signature process can be imagined as shown in Figure 5.1.:

Fig. 5.1 Process rent contract “signature”. From Karamitsos et al., 2018, p. 187.

As shown in Figure 5.1 both parties which are landlord and tenants sign the smart contract which represents a rental agreement. This rental agreement contains information such as the rental value, payment frequency and details of the landlord and the tenants (Karamitsos et al., 2018). This model is rather simplistic so if we want to get a more realistic overview we can look at the complete list that was made by IPF (2012). For the complete list of information that needs to be collected and exchanged see Appendix A. The list is rather long and complex which begs two questions immediately: ● Can a smart contract deal with the complexity and quirks of the process? ● Even if the smart contract can deal with complexity can we take it as legally binding? In the following we will look at the limitations of smart contracts and a possible solution.

64

5.2.1.1 Limitations of smart contracts The relationship between smart contracts and legal contracts are complex and there are also certain limitations. Meanwhile an educated and experienced developer could develop a smart contract it would be difficult for a lawyer without knowledge of a programming language to fully understand the smart contract. But in the real world natural human language should be used in order to audit contracts at any given time. Another limitation is that platforms for developing smart contracts are mainly public. It is an issue for business since there are corporate secrets and private data that should be kept secret. For tackling this problem permissioned blockchains are being more and more used. Lastly, when a smart contract is executed it is not possible to alter. Businesses need to react to the changing circumstances in the real world environments. Since agreements can often change smart contracts unfortunately can not provide the flexibility that would be needed.

It is not possible to predict the future for an agreement. Furthermore, some parts of the negotiations can be left out at the given time since the parties have not reached a consensus on the particular area yet. Smart contracts lack the flexibility which results in re-writing code which is complicated, time consuming and expensive. Levy refers to this problem as the following, “As such, it can be both operationally and socially beneficial to leave some terms underspecified; vagueness preserves operational flexibility for parties to deal with newly arising circumstances after an agreement is made and sets the stage for social stability in an ongoing relationship” (Levy, 2017).

Smart contracts are not able to deal with complex situations. The problem arises when the outcome of the smart contract and the demands of law do not match with each other. Let us take an example which will clear this limitation. Let us imagine that a person is not satisfied with the rejection of a payout. All parties involved must have access to legal authority which enables careful examination of the decision that is based upon blockchain.

5.2.1.2 Evolution of smart contract The analysis of the evolution of the smart contract regarding the past, the present and the future will help to figure out what this technology can really offer to us. The technology itself got popularity before Bitcoin already. The goal of the smart contract was to avoid the intermediary role from the system (Petersson, 2018). But the practical and effective use of smart contracts started after Bitcoin. As a future prospect the combination of big data, artificial intelligence and machine learning with blockchain and smart contracts is a possible scenario and is the main topic of many ongoing research all over the world. We have already looked at limitations of

65 smart contracts and in the following section we will look at the possibility of a hybrid smart contract. Even though smart contracts have benefits such as transaction costs and higher level of security the intersection of contract law and code will not remove completely disputes (Rogers, Jones-Fenleigh, Sanitt, 2017). Some of the legal issues regarding smart contracts are the following: ● Can we consider smart contracts legally binding? ● What is the solution in case of bugs in the code? ● How will smart contracts deal with the change of regulations and law? One of the main reasons against the enforcement of smart contracts is the lack of flexibility. Flexibility is indeed an important part of the traditional contracts. Due to the lack of this vital feature, it is safe to say that “For the foreseeable future at least, it is unlikely that code will be law. There are several legal issues and practical limitations arising from the fact that smart contracts are written in code instead of natural language” (Tse, 2018). Due to its digital nature smart contracts present an on-going debate which questions whether a computer program written in a particular programming language can represent a contract in a court of law. The goal of the smart contract is to represent a legally binding agreement between two parties but it is an absolutely different representational form. It creates the problem namely that the court of law does not understand the smart contract. So the question is if it is possible to develop smart contracts in a way that it is readable by machines and also by people. If both machines and people can understand the smart contract it would be accepted in a legal situation. Contracts did not change for a long time but “In response to the growing complexity of contracts, new approaches such as simplification, visualisation and user-centered design have been introduced, even to the world of commercial contracting” (Haaipo, Plewe, deRooy, 2017). Traditional contracts that were originally based on text now are moving towards visualized contracts. These types of contracts add images with the goal of enhancing readability and usability. In the future we might meet with various types of contracts such as text-only contract, visualized contract, smart contract or hybrids of all the previous. Regarding smart contracts a hybrid form that would be readable by humans and machines would be a next step since “There is a lot of potential in the dynamic interfacing between visualisation, text and coded contracts to simultaneously achieve the apparent contradictory goals of human and computer readability” (Haaipo, Plewe, deRooy, 2017). A Ricardian contract that would store contract details in a format that is readable by both humans and machines could be a feasible solution.

5.2.1.3 Ricardian contract The Ricardian contract was introduced by Ian Grigg in 1995. Grigg defined it as “a single document that is a) a contract offered by an issuer to holders, b) for a valuable right held

66 by holders, and managed by the issuer, c) easily readable by people (like a contract on paper), d) readable by programs (parsable like a database), e) digitally signed, f) carries the keys and server information, and g) allied with a unique and secure identifier ” (Grigg, 2004). He is a financial cryptographer and the man behind this new type of legal document. He developed the concept to digitize a legal contract or a financial instrument. Smart contracts are machine-readable contract. They act as a contract to give trust through an exchange process in blockchain. The contracts can be used in the exchange of money, property or other assets. The obligations between parties can be first defined then executed via code but the Ricardian contract solves the issue of obligations. Ricardian contract can be described as a document which defines a type of value for issuance. It specifies the issuer and any terms or clauses that the issuer finds important to add into the document. The contract needs to be readable by both machine and human and is formatted as a text file. The Ricardian contract can be illustrated by the following Figure 5.2 as below:

Fig. 5.2 Ricardian Contract. From Grigg, n.d. The contract consists of the important parts which make sure that the contract is legally enforceable and automated, i.e. parameters, code and prose (Haapio et al., 2017). These three elements could be thought of as a tuple of objects. The parameters join the appropriate parts of the legal contract to the equivalent code. The code represents the

67 representation of the legal prose that is readable by the machine. Finally, the prose is the actual, human readable legal contract. The diagram shows the World of Law on the left side. This is where the original document comes from. This document is hashed and the message digest is used as an identifier in the World of Accountancy. The World of Accountancy is any information or trading system that would be used in business to perform different actions. The message digest is first used in a genesis transaction. Then as an identifier it would be used in every later transaction. The following Ricardian contract example is taken from the library of CommonAccord12. The sample is part of a debt financing agreement:

Ricardian Contract. From Schönherr13

12 CommonAccord - CommonAccord is an initiative to create global codes of legal transacting by codifying and automating legal documents, including contracts, permits, organizational documents, and consents. [Online] Available at http://www.commonaccord.org 13 Schönherr - We are a full-service law firm with a footprint in Central and Eastern Europe providing local and international companies stellar advice. [Online] Available at https://www.schoenherr.eu/

68

5.2.1.4 Characteristics of Ricardian contract

The characteristics for a Ricardian contract can be listed as below (Grigg, n.d.):

1. Human parsable; 2. Printable document; 3. Program is parsable; 4. All versions i.e. displayed, printed, parsed are manifestly equivalent; 5. Signature of the Issuer; 6. All relevant information is present in one single document, including signature and parties. This, along with the manifestly equivalent characteristic above, results into the Rule of One Contract; 7. It can be represented as a legal contract; 8. It can be identified securely, wherein the securely means any attempt to distort the linkage between a reference and the contract is not feasible; 9. It is supported by financially capable PKI14 (such as OpenPGP15); 10. Extensible – It can interpret bonds, shares, loyalty, etc.; 11. It can identify legal issuer (signer of contract) and issuance server; 12. Cannot be changed by anyone except legal issuer or other parties of the contract; 13. Verifiable in nature;

5.2.1.5 Essential requirements for Ricardian contract If the goal is to create a smart contract that is legally enforceable there are certain requirements that need to be fulfilled. The following description gives a list of essential requirements (Clack et al., 2016):

1. “Methods to create and edit smart legal agreements, including legal prose and parameters. 2. Standard formats for storage, retrieval and transmission of smart legal agreements. 3. Protocols for legally executing smart legal agreements (with or without signatures). 4. Methods to bind a smart legal agreement and its corresponding smart contract code to create a legally-enforceable smart contract.

14 Public Key Infrastructure (PKI) is a technology for authenticating users and devices in the digital world. The basic idea is to have one or more trusted parties digitally sign documents certifying that a particular cryptographic key belongs to a particular user or device. The key can then be used as an identity for the user in digital networks. [Online] Available at https://www.ssh.com/pki 15 OpenPGP - OpenPGP is the most widely used email encryption standard. OpenPGP was originally derived from the PGP software and created by Phil Zimmerman. [Online] Available at https://www.openpgp.org/

69

5. Methods to make smart legal agreements available in forms acceptable according to laws and regulations in the appropriate jurisdiction.”

5.2.1.6 Comparison of smart contract and Ricardian contract Below is Table IV. summarising the differences between a smart contract and a Ricardian contract according to what we learn about them until now:

Property Smart Contract Ricardian contract

Purpose Execute the terms of an Record the terms of an agreement if certain agreement as a legal conditions are met. document.

Concerned with the Concerned with recording execution of the recorded an agreement. The agreement. It does not agreement is bound by involve legal prose. law.

Flow Automate actions on It can also automate blockchain-based operations on the applications blockchain-based applications

Validity It is not a legally binding It is a legally binding document document/agreement

Versatility Cannot be made into a Can include the Ricardian contract characteristics of a Smart contract as well and act as a Ricardian contract

Readability Machine readable. May or Human and machine may not be human readable but not readable. necessarily machine readable

Table IV. Comparison of Smart contract and Ricardian contract. From Author’s own table

70

The contract of the future will most probably be a hybrid where the Ricardian contract will be combined with the traditional and smart contract.

5.2.1.7 Current usage of Ricardian contract

5.2.1.7.1 OpenBazaar

There already existing solutions that use Ricardian contract namely OpenBazaar which “uses Ricardian contracts for managing trade and arbitration in a decentralised pseudonymous marketplace. Ricardian contracts enable tamper-proof and authenticated consensus between buyers and sellers, which can be easily audited by the contracted parties and an external 3rd party” (Grigg, n.d.).

So in OpenBazaar the Ricardian contract is a method to track the liability of one party when selling products to another. A contract represents a single unit of good or service. The Ricardian contract makes it possible to effectively track signed agreements between parties. The legitimately signed and binding agreements can not be forged after being signed.

These contracts digitally signed and checksum hashed which create an unalterable record of agreement for an exchange on a peer-to-peer network. Digital signatures will serve as a proof of agreement so signing means agreeing to the terms. Hashes will serve as a proof of authenticity. If the contract has been altered even the smallest possible change causes change in the hash.

5.2.1.7.2 Issuing a contract in OpenBazaar The contract is saved as an XML file with the SHA1 hash of the file. The XML file contains the following structure (Sanchez, 2018):

1. Contract terms - Seller's nym - Contract nonce (unique identifier) - Seller's bitcoin pubkey (for multisig transactions) - Merchant Data - What is to be sold - Price per unit - Additional conditional detail unforseen in this proposal - Contract expiration date - Seller's PGP16 public key

16 PGP encryption or Pretty Good Privacy encryption, is a data encryption computer program that gives cryptographic privacy and authentication for online communication. It is often used to encrypt and decrypt texts, emails, and files to increase the security of emails. [Online ] Available at https://digitalguardian.com/blog/what-pgp-encryption-defining-and-outlining-uses-pgp-encryption

71

2. All of the above is digitally signed with the seller's private PGP key

In the following example Alice wants to sell a 16 pound watermelon. She creates the contract below signs it with her her private PGP key and distributes it on the OpenBazaar network (Sanchez, 2018), as shown in Figure 5.3:

Fig. 5.3 Ricardian Contract - Seller. From Sanchez, 2018

72

Fig. 5.3 Ricardian Contract - Seller’s PGP public key. From Sanchez, 2018

5.2.1.7.3 Functionalities

The OpenBazaar17 website describes the functionalities and is described below:

Stage 1: Listing/Vendor Offer

i. The Vendor lists what is for sale (physical item, digital content, services etc.)

17 OpenBazaar - OpenBazaar is a different way to do online commerce. It’s a peer to peer application that doesn’t require middlemen which means no fees & no restrictions. [Online] Available at https://openbazaar.org

73

ii. There are some prior steps regarding Moderator selection that won’t be elaborated on in this article

Stage 2: Stage 2: Buyer Order

i. The Buyer sends an order to the Vendor ii. The Vendor acknowledges the order, sending a digital signature that will serve as a Vendor authentication of the order (prevents attackers from making fake ratings of the Vendor) iii. Buyer funds the multi signature escrow address

iv. Order processing time begins: 1-3 days to ship the item

Stage 3: Vendor Order Confirmation

i. The Vendor confirms to the Buyer that the order has been processed and the item has been shipped ii. Gives the Buyer any shipping related data, for physical goods iii. Gives the Buyer a download address and password, for digital content iv. Gives the Buyer any relevant data to perform the service v. Sends partially signed transaction releasing funds from the multi signature escrow address to the Vendor (still requires Buyer to sign after receiving the item)

Stage 4: Buyer Receipt

i. Buyer acknowledges that the item, content, or service was delivered/performed ii. Signs a transaction releasing funds from multi signature escrow iii. Makes a rating and review of the Vendor, sends the transaction summary to the Vendor and Moderator for storage

5.2.1.8 Summary

It seems that it might be possible to create a digital representation of real estate property on Blockchain. The process of due diligence can be digitized through the use of smart contracts.

The complexity of the legal system, the transactions and the proceedings of the legal professionals need to be considered in case a Blockchain based Land Registry system should be implemented. Due to the lack of standardizations such a plan might never could be fulfilled (Vos et al., 2017).

Literature and research argue that blockchain technology is not mature yet. Another issue is that there are no standards regarding the registration of real estate assets on

74 the Blockchain. If all the stakeholders wanted to communicate it would require a system on a global scale which means a common and standardized framework.

5.2.2. Efficient financing mechanism When both the seller and buyer agree upon the conditions the next step for the buyer is to arrange his finances. Financing traditionally is done via banks but crowdfunding real estate can be the next innovative investment structure (Marchand, 2016). Furthermore, the fact is that the time has come when banks will be obliged to lower their provision of capital. So getting credit will have higher costs and further regulations.

5.2.2.1 Crowdfunding According to Belleflamme et. al. (2013) “Crowdfunding involves an open call, mostly through the Internet, for the provision of financial resources either in the form of donation or in exchange for the future product or some form of reward to support initiatives for specific purposes.”

The crowdfunding process has three actors which are initiators, funders and intermediaries. The initiator is the one who initiates a request for funding. The funder will invest an amount of money and the intermediaries will take care of the technical aspects and the exchange of the funders between the funders and the intermediaries.

5.2.2.2 Crowdfunding models Donation based It is often used by non-profit organisation to attract donation for specific projects. Majority of donations are for charities but there are also few businesses that get funding through this model.

Reward based In this model the contributors get a reward that can range from a phone call to personal favour but the reward is not a percentage of the profit.

Loan-based In this model acquiring funds depends on loans. The loan is issued for a predefined period and are repaid with a percentage of interest.

Equity-based An equity loan may refer to a mortgage loan in which the borrower receives money. Typically the loan is secured by real estate already owned outright.

75

5.2.2.3 Blockchain based crowdfunding In case of Blockchain based fundraising the fundraisers could allow the crowdfunding shareholders to register their rights at low costs with the help of smart contracts (Zhu, Zhou, 2016). Blockchain has potential due to its characteristics which are security, distributed ledger, decentralised data management, transparency, anti-tampering and anti- forgery, efficiency, low cost (Guo, Liang, 2016; Zhu, Zho, 2016).

The following Table V. summarises the differences between traditional banking and how blockchain could resolve the issues in crowdfunding:

Traditional banking Blockchain based

Efficiency bottlenecks Complex clearing process; Distributed ledger; Automated; Large amount of manual Disintermediation inspection; Many intermediate links

Security of fund management A central trusted party; Point-to-point transmission; Complex equity transaction and Uniqueness of equity transaction transfer and transfer

Transaction lag Centralised data management; Decentralised data Leads and lags management;

Transactions are time-stamped and can be verified in near real- time

Cost High cost Low cost

Operation risk Use of information asymmetric Use of asymmetric encryption; which often leads to adverse Transparent selection and moral hazards;

Double payment

Table V. Comparison of traditional banking businesses and blockchain based banking businesses. From Guo, Liang, 2016, p. 6.

According to Zhu and Zho (2016) a Blockchain based voting platform that would allow shareholders to participate in corporate governance effectively. Also any malicious action

76 can be tracked because of smart contracts. Intermediaries such as banks and payment providers can be avoided through the implementation of digital currency.

5.2.2.4 Blockchain based mortgage funding Blockchain could provide transparency which would allow investors to identify ownership for debt and reduce the risk of corrupt behaviour by companies, regulators. According to Malinova ad Park (2016) in the Market Design with Blockchain Technology article they claim that transparency plays an important role for liquidity in the market. Cutting on the information asymmetry will reduce the advantage of brokers or insurance agency.

If the funding process was automated the investors could put their criteria, risk appetite and equity availability in to a smart contract. It could reduce the costs for the due diligence process. The risk analysis process would need an advanced tool that could analyze the risk for each mortgage. Another aspect is that transferring ownership and money would happen at the same time which requires a standard for data requirements. According to Gout (2017) who conducted a study on a blockchain based model for a mortgage funding marketplace the system would work around a smart contract. The smart contract would connect the various investors and would verify and validate the transfer of ownership. The complete process could be programmed into smart contract considering the phases namely initiation, diligence and closing: ● Initiation

Fig. 5.4 Smart contract - Initiation phase. From Gout, 2017

77

As shown in Figure 5.4, a borrower makes a request for a mortgage. The request has enough information so the smart contract can be executed and enough investors are found and matched to fund the loan. ● Due diligence

Fig. 5.5 Smart contract - Due diligence phase. From Gout, 2017

As shown in Figure 5.5, due diligence is taken care of automatically after the borrower and advisors uploading information. This information is verified by the smart contract. But not all the information is stored in the contract. Permission is for those who are coded into the contract.

● Closing

Fig. 5.6 Smart contract - Closing phase. From Gout, 2017. Edited by Author

78

All assets must be on the blockchain network. Payments are monitored and registered. Shares are made through transaction and mortgage contract.

As we can see the smart contract is the central point for the investors, the consumers, the land registry, the notary and the services etc. The operational costs are low since the diligence is automated. All the rules and legislations can be programmed into the smart contract and every action is verified and executed by the smart contract. The process can provide efficiency, speed and transparency.

5.2.2.5 Summary A trustless system can replace a concentric model that is based upon trusted institutions and access control. It takes the intermediaries out of the system. Smart contracts are able to execute complex programs without the need of intermediaries. In order to have a trustless system there is a need for transparency, economic motivation and consensus algorithm to provide integrity of data. Following these guidelines will make the system slow, consuming a lot of energy (Schär et al., 2019). Mortgage funding is a complex process and various stakeholders such as lawyers, credit agencies and trust funds are involved. For Blockchain as a technology it will if ever reached take time to be able to handle such complex processes and package solutions as mortgages. The true value of Blockchain in this matter is the possibility to track and trace the various processes that are automated and self executed. Real estate owners can look at the history of the tenants and every related information. According to Internet Telecommunications Union (2017) 52% of the world’s population does not have access to internet. The necessary infrastructure such as mobile networks and reliable electricity is missing. There is an absence of one common set of standards that can ensure the interoperability of systems across industry and supply chains (Niforos et al., 2017). Also “...the emergence of Blockchain technology as well as the increased popularity of equity crowdfunding are rather young phenomena. This implies that numerous legal questions remain unanswered. Currently, many countries are working on frameworks outlining how to deal with Blockchain-based crowdfunding” (Schär et al., 2019).

5.3 The operating process In this section we will look at the commercial management process of the operational phase and the advantages of the Blockchain technology that could be utilized.

5.3.1 Digital lease contracts The operational phase is divided into four parts which are commercial management, technical management, administrative management and promotional management.

79

During the commercial management and technical management information is collected and according to that an agreement is made between parties. In the administrative management phase all the collected information is organized and administered. Blockchain would have an opportunity in the process namely digital lease contracts. Information exchange is the relation between the tenants and the owner via a lease contract. The process of validation is still based on traditional methods. Information from various actors such as banks, tenant, property owner and government needs to be collected and the contract between the tenant and the owner needs to be signed as well. The lease agreement is made when all the obligations are fulfilled. Transactions of payments and services need to be made, validated, tracked and stored. The cash flow needs to be checked by the owner of the real estate and other parties such as financial regulatory authorities and banks. It means that the cash flow and related costs need to be controlled which results in strict accounting practices. The possibility for Blockchain would be the use of smart contracts which make the management of property and cash flow more convenient, transparent and efficient.

5.3.1.1 Deloitte Deloitte (2016) is exploring the possibilities and they claim that Blockchain can be used in lease transactions by: ● Using smart contracts for creating lease agreements ● Using smart contracts for automated payment and cash flow management

With the use of blockchain the process of blockchain based lease contracts would look like in the following Figure 5.7 (Deloitte, 2016):

1. Both parties digitally sign the smart contract (agreement), which includes details such as rental value, payment frequency, and tenant and property details.

80

2. Based on the terms of the contract, the smart contract periodically initiates the lease payments from the tenant to the landlord and the contractors

3. On termination of the lease, the contract triggers the payment or security deposit back to the tenant after adjusting for any damage repair charges.

5.3.2 Summary The Deloitte system is built on top of Bitcoin. Every user gets a unique address which can verify the authentication of signature. The hash of transaction is added on the blockchain and linked to the original contract. The agreement between the tenant and the landlord happens through two Bitcoin transactions. Deloitte needed to face the problem of dealing with the exchange of ownership. Further development and research is needed in the future.

81

5.4 Technical challenges Blockchain is being praised as a technological breakthrough that will solve a big amount problems we currently face the other side of the coin is that it faces a number of unique challenges. These challenges are not unsolvable by their nature but they require a research and development to overcome so safe infrastructures and efficient mechanisms can be created. The goal of this section is to look at some of the main challenges Blockchain suffers from and get a better understanding of these flaws so we can make a logical and well thought decision when we would be planning to use the technology in our project.

5.4.1 On-chain storage The block size of Ethereum is variable. The advantage of storing a large file in a single block is that the hash that is used for the validation in the next block will still be 32 bytes and it will not have a negative effect on the rest of the chain (Wood, 2019). The first problem with storing large files on Ethereum is that the cost of transaction increases proportionally to the size of the file. From a technical perspective a word of 256 bit size would cost 20,000 Gas which means that a 1 megabyte sized piece of data would have a fee of 625 million Gas (Wood, 2019). If we take the current prices such a single transaction would cost several thousands of Euros. Secondly the block size is based on the votes of the miners. So if the miners decides to increase the gas limit the size of the block increases as well. The miners need to allow to store large files in the end. Even though the block size grew proportionally to the amount of transactions the size of a single block has only once exceeded 35 kilobytes as shown in Figure 5.8:Fig Fig 5.8 The average block size of Ethereum18. The Ethereum Average Block Size Chart indicates the historical block size in bytes of the Ethereum blockchain

18 Etherscan - Etherscan is a Block Explorer and Analytics Platform for Ethereum, a decentralized smart contracts platform. [Online] Available at https://etherscan.io/chart/blocksize

82

5.4.2 Off-chain storage As we saw on-chain storage is not really a good solution if we consider finance and other technical practicalities. One solution is to store the hash of data on the chain. A hash value is small in size. The issue that smart contracts and distributed hash tables (DHT) try to solve is to make a link between the hash and the storage.

5.4.2.1 Smart contract As we saw it was possible to store hash in a Blockchain but we also need to access the data. We need to know who has a copy of the data and this type of information is stored in a smart contract. As we discussed earlier, smart contracts are programmed and irreversible. Let us imagine a situation where Alice stores 100GB of data with Bob. Alice and Bob made an agreement that Bob would store this amount of data for 1 year with a fee of 100 Euros. The problem in this scenario is that if Bob is accidentally offline then Alice will have no access to her data even though Bob kept his part of the agreement and still stores the data. But it is not enough that Bob stores the data there should be a guaranteed access for Alice to her data.

5.4.2.2 Hash tables One solution to the above mentioned problem can be that there would be multiple copies of a file stored in a network so we could avoid the single-point-of-failure problem. Distributed hash tables could serve as a network of storage locations where the index will define what type of data is stored in the storage. In case of Blockchain this index is stored in a decentralized manner.

5.4.2.3 IPFS Another approach for off-chain storage solution is the Interplanetary File System (IPFS). IPFS is a distributed file system that is based on peer-to-peer technology and as a distributed system it has the advantage that “has no single point of failure and nodes do not need to trust each other” (Benet, 2014).

The transportation of large files happens by splitting the files into multiple parts which are called chunks and are the size of 256kB (Benet, 2014). IPFS could be compared to a domain name system where each user gets a namespace. The namespace is linked to a hash value that will represent the particular file in IPFS. If the content is changed a new hash value is made and the pointer with the new hash value will point to the changed to the new file.

Confais et al. (2017) made a performance analysis with IPFS. The results in reading and writing time while changing the size of the file and latency are shown in Figure 5.10:

83

Fig. 5.10 Mean time using IPFS

In the tests data was sent between local machines and the latency was changed between the servers. As the results showed the increased latency had a higher impact on time for smaller files than for larger files. It was faster to write file when small files with 20ms latency were tested.

According to Benet (2014) “At the bare minimum, it can be used as a global, mounted, versioned filesystem and namespace, or as the next generation file sharing system. At its best, it could push the web to new horizons, where publishing valu- able information does not impose hosting it on the publisher but upon those interested, where users can trust the content they receive without trusting the peers they receive it from, and where old but important files do not go missing”.

5.4.3 Denial-of-Service attacks We imagine a denial-of-service attack as a malicious actor overwhelming a website with so many requests that it cannot respond effectively. In the case of Ethereum it happened a bit differently.

Every operation type in the Ethereum Virtual Machine has its price but some operations were mispriced therefore they did not show the actual computational power that was needed to execute them (Chen et al., 2017). A malicious attacker deployed a smart contract and by calling it slowed down the Ethereum network since the smart contract performed a very memory intensive work. A hard fork was the only possible solution to solve the mispricing.

5.4.4 DAO hack DAO is a digital decentralised autonomous organisation and a form of venture capital fund that is focusing on a new decentralised business model (Wang et al., 2019). DAO is built on Ethereum platform thus the value token is called Ether. A hacker managed to misuse the reinjection vulnerability and to transfer 60 million dollars worth of Ether to an intermediate contact. The issue in this case was that when the amount of Ether was withdrawn it was sent to the hacker and only then was the withdrawer’s balance updated

84 to 0. The hacker managed to to request payouts before the balance was updated. The following lines of code will demonstrate the splitDAO() function where the user could withdraw Ether and move to their own DAO (Bambara et al., 2018, p. 223):

withdrawRewardFor(msg.sender); // The receiver gets paid out here totalSupply -= balances[msg.sender]; // only now is the receiver's balance updated -- balances[msg.sender] = 0;

// PROBLEM BELOW: This should have been done first before payout paidOut[msg.sender] = 0; return true;

5.4.5 Scalability Scalability is one of the biggest challenges. The number of transactions for Bitcoin is 7 meanwhile for Ethereum around 15. Every transaction is performed by every node and the processing power of a single node can affect the entire network in a negative way. If there is an amount of nodes with powerful computers then the network can not be considered decentralized.

Blockchain is slow compared to banks that deal with credit card transactions. “Visa processes 150 million transactions per day, averaging roughly 1,700 transactions per second. The company's capability actually far surpasses that, at 24,000 transactions per second19”.

There is a constant debate about the scaling problem and there seems to be two major solutions:

● Making the transaction faster and cheaper by making the amount of data that needs to be verified in every block smaller ● Making the amount of information that should be processed at once higher by making the blocks themselves holding more data

5.5 Ten-step decision path Having looked at the inner functioning, possible use cases and drawbacks of Blockchain it can still be a challenging task to make a final decision about using this technology. Pedersen et al. (2018) made a framework that would make this decision easier. “The framework comprises a ten-step decision path for determining if a blockchain is

19 Investopedia - Bitcoin vs. Bitcoin Cash: What is the Difference? - By Jake Frankenfield Updated Apr 20, 2019 [Online] Available at https://www.investopedia.com/tech/bitcoin-vs-bitcoin-cash-whats- difference/

85 applicable and deciding what kind of blockchain solution would be most suitable” (Pedersen et al., 2018).

Fig. 5.11 Overview of the Blockchain Decision Path. From Pedersen et al. (2018)

The decision process consists of 10 steps as shown in Figure 5.11 and the process can be divided into two parts. The first seven questions can help to figure out if it was useful and feasible to use the Blockchain technology. The last three questions are concerned with choosing the type of Blockchain we would use.

These yes-no questions can serve as a guide to decide when to use Blockchain and which type of it but the process in reality requires more complex research where requirements and constraints. As Pedersen et.al (2018) stated “we usually advise that a blockchain is feasible if at least five out of the first seven questions are answered with”. But the careful consideration of paradoxical business and design requirements is still necessary for every professional.

5.6 GDPR GDPR or in another terms General Data Protection Regulation came into force on May 25 in 2018. It was made to modernise law that protects personal information of individuals. GDPR changes how businesses and public sector organisations should take care of customer information. It gives more rights for the individuals to have more control over their collected information.

86

But it seems Blockchain and GDPR have obvious contradictory characteristics. Firstly, GDPR assumes that there is at least one legal person to whom the data subject could go to and enforce rights under the new law. By data subject we mean the person whose data was collected. Blockchain on the other hand is trying to remove the legal person that GDPR would give rights to.

Secondly, GDPR would give the right for data subjects to modify or erase information. Such operations in Blockchain are rather burdensome because the purpose is data integrity and trust in the network.

Thirdly, GDPR would minimize data and limit purpose by principle which means that GDPS requires the collected data to be kept at a minimum and only being used for purposes that the data subject knows. Such principles are difficult to apply to Blockchain because distributed ledgers are append-only databases that grows continuously. Also, in case of Blockchain technology data is replicated on every node that participates in the network.

According to a study conducted by Finck (2019) requested of the Panel for the Future of Science and Technology (STOA) at European Union “the very technical specificities and governance design of blockchain use cases can be hard to reconcile with the GDPR”. Furthermore, the study also highlights that “the lack of legal certainty pertaining to numerous concepts of the GDPR makes it hard to determine how the latter should apply both to this technology and to others”. Since GDPR is rather a new regulations companies still have difficulties fully understanding and integrating it in their processes so combining GDPR with Blockchain technology which has potential but no proven, long-term and empirical data is a challenge and requires more work and research.

5.7 DApp development For developing a decentralized application we used the Ethereum blockchain and related technologies and in the end we used a today commonly used technology stack with its advantages and disadvantages.

But as we saw the development process was not just merely different from a traditional software development process but also complicated to a level where we need to answer the question whether such a solution is really what we strive for.

In particular I would like to address the part of the development which is concerned about the wallet which is in our case was the MetaMask extension. After seeing the cumbersome nature of development the question arises. Can we implement a Blockchain based application without the mining process hence there would be no need to use Ether on the Ethereum Blockchain?

87

Instead of the Proof-of-Work algorithms that requires mining we could use Proof-of-Stake algorithms that require forging. In simple terms instead of using processor power it is randomly allocated to one of the forgers being present on the network. But a base currency still functions as an incentive. The entire system would run into the problem of getting users to maintain the network if there was no cryptocurrency to motivate to give their processing power.

A Blockchain network called Ripple20 is planned to be used mainly for financial solutions. The Ripple network works on a consensus method in which all the nodes who participate on the network validate the transactions and balance. Transaction is only recorded in the system if a minimum number of nodes reach a consensus. The project has successfully eliminated the need of miners but mining as a process will be still vital to the verification of the transactions.

5.8 Swedish Lantmäteriet An interview was conducted with Mats Snäll who is the leader of a project that is discovering the possibilities of using blockchains as a technical solution for real estate transactions in Sweden. The Swedish government agency Lantmäteriet21 which is the national mapping, cadastral and land registration authority partnered with the telecommunication firm Telia22, consulting firm Kairos Future23 and blockchain technology company ChromaWay24 to develop a blockchain-based platform for conducting real estate deals. In summary the problems with Lantmäteriet according to Mats Snäll are the following: ● Lantmäteriet is only involved in some steps in the real estate transaction which means that the entire process is not transparent to the public or to the various actors ● It is the norm that the time between signing a contract for buying and Lantmäteriet getting the bill and approving can be up to six months

20 Ripple - Powering the Internet of Value. The XRP Ledger is open-source technology that anyone can use [Online] Available at https://xrpl.org/#key-takeaways 21 Lantmäteriet - Lantmäteriet is an authority belonging to the Ministry of Finance. We are responsible for the real estate division in Sweden and provide society - public sector, business and private individuals - with information on geography and real estate. [Online] Available at https://www.lantmateriet.se/en/ 22 Telia - Telia is a Swedish multinational telephone company and mobile network operator present in Sweden, Finland, Norway, Denmark, Lithuania, Latvia and Estonia. [Online] Available at https://www.telia.se/ 23 Kairos Future - Kairos Future is an international consulting and research company that assists companies and organizations to understand and shape their futures. [Online] Available at https://www.kairosfuture.com 24 ChromaWay - ChromaWay has also been a pioneer within using blockchain technology, being part of the first project to have a bank issue a currency on the Bitcoin Blockchain with LHV Bank in 2014. ChromaWay is also the first company to have the first Western government exploring blockchain for Land Registry with the Swedish Lantmäteriet. [Online] Available at https://chromaway.com/aboutus/

88

● Lastly, the various actors such banks, real estate agencies have their own processes which create inefficient and complex processes for the whole real estate process A non-technical and simplified overview of the technical solution is shown in Figure 5.12:

Fig. 5.12 Simplified overview of the technical solution. From The Land Registry in the blockchain, 2016, p. 33.

As shown in Figure 5.12 the Blockchain is public and verified by anyone but the Blockchain is checked by the Lantmäteriet. Signing and authorizations of chain could be edited. The bill for selling and buying a property would be saved as a verified record by Blockchain. The original documents could be stored by an external party that is agreed upon. The documents and their verifications are recorded in external Blockchain which creates the trust within parties.

According to Mats Snäll the main motivations for the project was to investigate the possibilities of the Blockchain technology:

● To make real estate transactions more transparent since there are more parties are involved in the whole process thus create trust between them. As it as mentioned earlier he said there are steps which are not public. ● To make real estate transactions more efficient by digitalization since at the current stage paper based solutions rule majority of the processes. Even though he mentioned that still the Swedish system is still comparatively very well functioning and that digitalization is also advanced in the country, the real estate industry is lacking behind. ● To make the system less centralized. According to him the total decentralization of this area is not feasible in the near future because there are more than one sectors who are involved and these sectors should make a common effort to advance towards a common goal at the same time.

89

Unfortunately Mats Snäll could not provide an in-depth description of the technical details. ChromaWay was the company responsible for creating the functioning prototype and for all the technical details. Therefore the company was contacted but there was no reply from them.

The main reason why the project was put on hold for an uncertain period of time was the lack of regulations in place. This aspect gets more complex since there are more parties such as banking, law, government and the real estate itself. A solution needs to address all the aspects of these parties’ field.

The project is bald and no one can foresee the outcome. But it seems that the complexity of the project as a whole and the lack of existing regulations won over the hype this time. Even though the National Swedish Bank is investing a large amount of its resources to research how Blockchain technology could be utilized there is no empirical evidence just yet.

Complexity and regulatory issues related to Blockchain are the reality even if they sound as harsh criticism which will be addressed in a later section of the thesis. There is no reason to take a side at this stage but to continue the work and research the subject in depth and focus on producing empirical evidence and data that could be used for further advancements.

90

Part VI - Conclusions

6. Conclusions The commercial real estate industry is a complex field with its limitations such as middleman, inefficient processes and record keeping of all contracts, transactions within all the parties. The Blockchain technology can exchange these digitally which would make the administration process much easier and more efficient.

The goal was to research the possible use cases of the Blockchain technology in the real estate management process. In order to do so first a technological background into Blockchain technology was given. Then a theoretical background into the real estate management process was given. After that we looked at in which phases of the real estate management process could the Blockchain technology be used.

In simple terms Blockchain is a database of transactions where the copies of the database are replicated across multiple nodes. These replicated copies are constantly getting updated and all the participants share the same and latest copy.

Even though the technology is praised a lot the fact is that it is at its early stage. Which also means that there are challenges and limitations that need to be addressed. These challenges are public perception, standardization, governmental regulation and general adoption. In order for the technology to grab attention from the wide publicum functioning and tested applications need to be developed that prove themselves in the course of time.

The different possibilities for the Blockchain technology to be implemented in the real estate management process will be shortly summarized below.

The various parties or also known as stakeholders can rely on the same data that can be trusted by every participant who is on the network without the need of a third party. The real estate transactions and due diligence process will become more efficient. Currently important documents can go missing or lack some details therefore not usable. If the transactions are Blockchain based it will reduce costs and will save money. Introducing smart contracts will make the work with lease agreements more efficient since the monitoring will be automated. Administration of all related information thus documentation will be trusted by all parties and will be maintained automatically. It will save time and money and will add transparency to the markets and manual data verification by broker firms will be reduced.

But until these rather ambitious goals will happen certain advancements need to take place. Firstly, technical standards need to be developed and agreed by all the countries

91 who would like to adopt the technology. Besides the technological aspects the domain areas need to get ready for the adoption and its consequences. This leads us to the next challenge which is that every country has its own system with business practices when we talk about for example the real estate industry. Now it seems a rather impossible mission to change all these various systems throughout many countries especially when their current system would be functional meaning the countries would not have in interest in changing their systems because on a cost and benefit analysis they would rate their system on the positive side. So changing all the current systems and their business processes into a uniform system based on Blockchain is simply delusional.

Even though Blockchain is not mature yet but there are already discussions how to harvest the possibilities of combining Blockchain with Artificial Intelligence to maximize the benefits. Those benefits which are not exactly clear since empirical support is lacking.

Blockchain has proven itself with digital currencies but other industries unfortunately can not showcase a proof of concept just yet. At this stage it is hard to foresee what the future holds. The good side of the current hype is that the technology gets a lot of attention and a lot of research is done by businesses, governmental and finance agencies or tech giants as a matter of fact in order to investigate the possibilities for different industries. By now the only thing we can do is to keep us updated and keep a critical eye on the topic and the advancements.

92

Part VII - Research limitations 7. Research limitations

The Blockchain is indeed a new technology that got the interest of many fields. Even though there are a lot of people around the world who are investigating the possible use cases in various areas of life the quality of these researches vary and some domain areas seem to get more attention than others. It is the case with real estate. The scientific research on how Blockchain could be used in real estate is limited. Due to this thesis was more of an exploration in its nature and the limitations are mentioned in this section.

7.1 The hype around Blockchain It is not an exaggeration to say that Blockchain as a technology is overhyped. Every day more and more articles and publications are being produced on it which look at the technology either too optimistic or they are simply just biased which makes it difficult to differentiate reality from fiction. Collecting scientific data with up to date and solid scientific arguments was therefore complicated.

7.2 The depth of the thesis The scope of the thesis was limited to the real estate management process and within that only a few aspects of it. It is due to the fact that real estate is a broad field with many aspects. This resulted in a limitation of depth. Also the lack of professional background domain knowledge of the author was a factor. But I believe if not fully understanding but just getting at least a sufficient knowledge on the domain was necessary in order to consider what possible opportunities Blockchain could have for this broad field.

7.3 Regulations and law These two topics are closely linked to Blockchain and they have been addressed in the thesis to a low level but they are out of the expertise of the author. Also, considering the legal issues regarding Blockchain could have been the topic for another thesis.

7.4 Complexity Understanding the basic guiding principles of the Blockchain technology can be relatively simple with the quality material. The additional complexity is added when we want to investigate its potential on a field like real estate which includes other areas such as law or banking. Since these fields are interconnected, it is important to have a necessary and broad overview so all possibilities with the necessary depth can be investigated and concluded upon.

93

7.5 Lack of real world use cases The biggest limitation is that even though we can read a lot of the game changing aspects of the Blockchain technology there are no actual results that would show us the full potential. In the thesis some start up projects were mentioned but more research is needed with sufficient empirical data.

94

Bibliography

B

Back, Adam. (1997) Hashcash. Retrieved from: http://www.cypherspace.org/hashcash/. Accessed at October, 2019. Bambara, Joseph; Allen, Paul; Madsen, Rene; (2018) Blockchain: A Practical Guide to Developing Business, Law, and Technology Solutions. McGraw-Hill Education; 1st edition. ISBN-10: 1260115879. ISBN-13: 978-1260115871. Baran, Paul. (1964) On Distributed Communications Network. IEEE Transactions of the Professional Technical Group on Communications Systems. Volume CS-12, Number 1. Printed in U.S.A. Bashir, Imran. (2017) Mastering Blockchain: Deeper insights into decentralization,cryptography, Bitcoin, and popular Blockchain frameworks. Packt Publishing. ISBN-10: 1787125440. ISBN-13: 978-1787125445 Bayer D., Haber S., Stornetta W.S. (1993) Improving the Efficiency and Reliability of Digital Time-Stamping. In: Capocelli R., De Santis A., Vaccaro U. (eds) Sequences II. Springer, New York, NY Benet, Juan. (2014) IPFS - Content Addressed. Versioned, P2P File System. Bosak, Alexander; Mayer, Bernhard; Vogel, Hubert (2007) Real Estate Management. Vienna: Europolis Real Estate Asset Management GmbH.

C

Castro, Miguel; Liskov, Barbara. (1999) Practical Byzantine Fault Tolerance. OSDI. Chaum, David. (1985) Security without identification: transaction systems to make big brother obsolete. Communications of the ACM. Volume 28. Issue 10, 1030–1044. 10. Chen, Ting; Li, Xiaoqi; Wang, Ying; Chen, Jiachi; Li, Zihao; Luo, Xiapu; Au, Man Ho; Zhang, Xiaosong. (2017) An Adaptive Gas Cost Mechanism for Ethereum to Defend Against Under-Priced DoS Attacks. Information Security Practice and Experience: 13th International Conference, ISPEC 2017, Melbourne, VIC, Australia, December 13–15, 2017, Proceedings (pp.3-24). DOI: 10.1007/978-3-319-72359-4_1. Clack, Christopher; Bakshi, Vikram; Braine, Lee. (2016) Smart Contract Templates: essential requirements and design options. C.D. Clack, V.A. Bakshi and L. Braine. arxiv:1612.04496. 2016. Confais, Bastien; Lebre, Adrien; Parrein, Benoît. (2017) An object store for Fog infrastructures based on IPFS and a Scale-Out NAS. RESCOM 2017, Jun 2017, Le Croisic, France. pp.2. Hal-01559065

D

Dai, Wei. (1998) B-money.Retrieved from: http://www.weidai.com/bmoney.txt. Accessed at: October, 2019. Deloitte. (2016) For the first time lease agreements are recorded in blockchain. Retrieved from Deloitte: https://www2.deloitte.com/nl/nl/pages/about-deloitte/articles/for-the-first-time- lease- agreements-are-recorded-in-blockchain.html Accessed at December, 2019

95

E

Elliott, Francis. (2009) Chancellor Alistair Darling on brink of second bailout for banks. The Times. 3. Retrieved from: https://www.thetimes.co.uk/article/chancellor-alistair-darling-on-brink- of-second-bailout-for- banks-n9l382mn62h. Accessed at October, 2019. Eyal, I.; Sirer, E. G. (2014) “Majority is not enough: Bitcoin mining is vulnerable” in Proceedings of International Conference on Financial Cryptography and Data Security. Berlin. Heidelberg. pp. 436– 454.

F

Finck, Dr Michèle; (2019) Blockchain and the General Data Protection Regulation. Can distributed ledgers be squared with European data protection law? EPRS | European Parliamentary Research Service. Scientific Foresight Unit (STOA) PE 634.445.

G

Geltner, David M. ; Miller, Norman G. (2001) Commercial Real Estate Analysis and Investments. ISBN-10: 0324305486. ISBN-13: 978-0324305487. Nashville. South-Western. Grigg, Ian. (n.d.) “Guide to Ricardian contracts” (WebFunds Project). Retrieved from: http://www.webfunds.org/guide/ricardian.html. Accessed at: December, 2019. Guo, Ye; Liang, Chen. (2016) Blockchain application and outlook in the banking industry. Financial Innovation. 2. 10.1186/s40854-016-0034-9.

H

Haaipo, Helena; Plewe, Daniela; deRooy, Robert. (2017) “Contract Continuum: From Text to Images, Comics, and Code”. In Erich Schweighofer et al. (Eds.), Trends and Communities of Legal Informatics. Proceedings of the 20th. International Legal Informatics Symposium IRIS 2017. Österreichische Computer. Gesellschaft, Wien 2017, Pg. 415. (ISBN 978-3-903035-15-7) Accessed at: December, 2019 Haber, Stuart; Stornetta, W. Scott. (1991) How to time-stamp a digital document. Journal of Cryptology, Vol. 3, No. 2, pp. 99–111. Hashrate Distribution. Blockchain. Blockchain Luxembourg S.A. Retrieved from: https://www.blockchain.com/pools. Accessed at December, 2019. Hordijk, Aart; Teuben, Bert (2008) The liquidity of direct real estate in institutional investors' portfolios: The Netherlands. Journal of Property Investment & Finance, Vol. 26 Iss 1, 38-58.

I

IBM Global Business Services. (2014) Device democracy - Saving the future of the Internet of Things. New York: IBM Corporation. International Telecommunications Union (ITU) (2017), Fast Forward Progress: Leveraging Tech to Achieve the Global Goals, ITU, Geneva, Switzerland: ITU IPF. (2012) Readiness for Sale: A guide for streamlining commercial property transactions. Investment Property Forum (IPF).

96

K

Karamitsos, I. , Papadaki, M. and Barghuthi, N. (2018) Design of the Blockchain Smart Contract: A Use Case for Real Estate. Journal of Information Security, 9, 177-190. doi: 10.4236/jis.2018.93013. King, S.; Nadal, S. (2012) “Ppcoin: Peer-to-peer crypto-currency with proof- of-stake” Self- Published Paper. August, vol. 19.

L

Lampic, Jurij. (2019) “Ricardian contracts: A smarter way to do smart contracts?” Schönherr. Retrieved from https://www.schoenherr.eu/publications/publication-detail/ricardian-contracts-a- smarter-way-to-do-smart- contracts/ Accessed at December 2019 Lamport, Leslie; Shostak, Robert; Pease, Marshall. (2002) The Byzantine Generals Problem. ACM Trans. Program. Lang. Syst.. 4. 10.1145/357172.357176. Leussink, Klass. (2018) CAP theorem. CryptoGraphics. CyrptoGraphics.info. Retrieved from: https://cryptographics.info/cryptographics/blockchain/cap-theorem/ Accessed at: December, 2019. Levy, Karen. (2017) Book-Smart, Not Street-Smart: Blockchain-Based Smart Contracts and The Social Workings of Law. Engaging Science, Technology, and Society 3 (2017), 1-15. DOI:10.17351/ests 2017.107 Lin, I.C.; Liao, T.C. (2017) A Survey of Blockchain Security Issues and Challenges. IJ Network Security, Vol. 19. (Issue 5), 653-659.

M

Malinova, Katya; Park, Andreas (2016). Market Design with Blockchain Technology. Business. DOI:10.2139/ssrn.2785626 Marchand, F. (2016) Crowdfunding Real Estate: Institutions and Markets. Delft University of Technology. McNamara, P. (1998) Exploring Liquidity, recent survey findings. Paper presented to 7th IPD Investment Strategies Conference. Brighton. Michael, J.; Cohn, A.; Butcher, J. R. (2018) BlockChain technology. The Journal, 34- 44. Miles, Mike E., Berens, Gayle L., Eppli, Mark J., Weiss, Mark A. (2007) Real Estate Development, Principles and Process. ISBN-10: 0874209714. ISBN-13: 978-0874209716The Urban Land Institute

N

Nakamoto, Satoshi. (2008) Bitcoin: Peer-to-Peer Electronic Cash System. Retrieved from: https://web.archive.org/web/20140320135003/https://bitcoin.org/bitcoin.pdf from original on 20 March 2014. Accessed at October, 2019. Narayanan, Arvind; Bonneau, Joseph; Felten, Edward; Miller, Andrew; Goldfeder, Steven. (2016) Bitcoin and Cryptocurrency Technologies. Princeton University Press; Edition. ISBN-10: 0691171696. ISBN-13: 978-0691171692

97

Narayanan, Arvind; Bonneau, Joseph; Felten, Edward; Miller, Andrew; Goldfeder, Steven (2016) Bitcoin and cryptocurrency technologies: a comprehensive introduction. Princeton: Princeton University Press. ISBN 978-0-691-17169-2. Niforos, M.; Ramachandran, V.; Rehermann, T. (2017) Block Chain : Opportunities for Private Enterprises in Emerging Market. Second and Expanded Edition. International Finance Corporation. World Bank Group. Washington, D.C. Nomura Research Institute. (2016) Survey on Blockchain Technologies and Related Services. FY2015 Report. Japan’s Ministry of Economy, Trade and Industry (METI)

P

Pedersen, Asger B.; Risius, Marten; Beck, Roman; (2019) A Ten-Step Decision Path to Determine When to Use Blockchain Technologies. (18:2) | MIS Quarterly Executive DOI: 10.17705/2msqe.00010 Petersson, David. (2018) “How Smart Contracts Started And Where They Are Heading”. Retrieved from: https://www.forbes.com/sites/davidpetersson/2018/10/24/how-smart-contracts- started-and-where-they-are- heading/#9e616e337b63. Accessed at: December, 2019.

R

Raval, Siraj (2016) "What Is a Decentralized Application?". Decentralized Applications: Harnessing Bitcoin's Blockchain Technology. O'Reilly Media, Inc. pp. 1–2. ISBN 978-1-4919- 2452-5. OCLC 968277125. Rogers, J., Jones-Fenleigh, H. & Sanitt, A. (2017) Arbitrating Smart Contract disputes. International arbitration report 2017 – Issue 9. Norton Rose Fulbright.

S

Sanchez, Dr Washington. (2018) Ricardian Contracts in OpenBazaar. Retrieved from https://gist.github.com/drwasho/a5380544c170bdbbbad8 Accessed at December, 2019 Schär, Fabian; Roth, Jakob; Schöpfer, Aljoscha. (2019) The Tokenization of Assets: Using Blockchains for Equity Crowdfunding. SSRN Electronic Journal. 10.2139/ssrn.3443382. Singhal, Bikramaditya; Panda, Priyansu Sekhar; Dhameja, Gautam. (2018) Beginning Blockchain: A Beginner’s Guide to Building Blockchain Solutions. Apress, Berkeley, CA ISBN- 13 (pbk): 978-1-4842-3443-3. ISBN-13 (electronic): 978-1-4842-3444-0. DOI: https://doi.org/10.1007/978-1-4842-3444-0. Library of Congress Control Number: 2018945613 Stallings, William; Brown, Lawrie. (2018) Computer Security: Principles and Practice. Global Edition 4th Edition. Kindle Edition Pearson. 4 edition Amazon Australia Services, Inc. ASIN: B07RX2RK8D Subramanian, Hemang. (2017) Decentralized Blockchain-based electronic marketplaces. Communications of the ACM. 61. 78-84. 10.1145/3158333. Szabo, Nick. (1994) Smart Contracts. Nick Szabo's Essays, Papers, and Concise Tutorials. Retrieved from: http://www.fon.hum.uva.nl/rob/Courses/InformationInSpeech/CDROM/Literature/LOTwinterscho ol2006/szabo.best.vwh.net/smart.contracts.html. Accessed at: November, 2019.

T

The Land Registry in the blockchain (2016) A development project with Lantmäteriet (The Swedish Mapping, cadastre and land registration authority), Telia Company, ChromaWay and

98

Kairos Future. Framtidens husköp i blockkedjan. Retrieved from http://ica- it.org/pdf/Blockchain_Landregistry_Report.pdf Accessed at December, 2019. Tse, Gary. (2018) Smart contracts: a boon or bane for the legal profession? Lexology. United Kingdom. Taylor Vinters Via LLC. Retrieved from: https://www.taylorvinters.com/article/smart- contracts-a-boon-or-bane-for-the-legal-profession Accessed at: December, 2019.

V

Vos, J., Lemmen; C. H. J.; Beentjes, B. (2017). Blockchain-based Land Administration: Feasible, Illusory or Panacea? In Responsible Land Governance: Towards and Evidence Based Approach, Washington, D.C. March 20-24, 2017 : Proceedings of the Annual World Bank Conference on Land and Poverty in Washington, D.C.: The World Bank. Voshmgir, Shermin; Kalinov, Valentin. (2017) Blockchain A Beginners Guide. Publisher: BlockchainHub Berlin, https://blockchainhub.net/ Licence: Creative Commons - Attribution. Share Alike. Vrijhoef, Ruben; Koolwijk, Jelle; Kuij, Reinier; Oel, Clarine; Wamelink, Hans. (2014) Developing a monitor for the characterisation of supply chain collaboration and the measurement of its effectiveness in the Dutch social housing sector. Conference: The CIB W55/65/89/92/102/117 & TG72/81/83 International Conference on Construction in a Changing World, At Heritance Kandalama, Sri Lanka

W

Wang, Shuai; Ding, Wenwen; Li, Juanjuan; Yuan, Yong; Ouyang, Liwei; Wang, Fei-Yue. (2019). Decentralized Autonomous Organizations: Concept, Model, and Applications. IEEE Transactions on Computational Social Systems. PP. 1-9. 10.1109/TCSS.2019.2938190. Wood, Dr Gavin. (2019) Ethereum: A secure decentralised generalised transaction ledger. Byzantium version 7e819ec. Retrieved from https://ethereum.github.io/yellowpaper/paper.pdf. Accessed at December, 2019. Wright, Aaron; De Filippi, Primavera. (2015) Decentralized Blockchain Technology and the Rise of Lex Cryptographia. SSRN Electronic Journal. 10.2139/ssrn.2580664.

X

Xu Xiwei; Weber Ingo; Staples Mark (2019) Existing Blockchain Platforms. In: Architecture for Blockchain Applications. Springer, Cham. Print ISBN: 978-3-030-03034-6. DOI: https://doi.org/10.1007/978-3-030-03035-3_2

Z

Zheng, Zibin; Xie, Shaoan; Dai, Hong-Ning; Chen, Xiangping; Wang, Huaimin. (2017) An Overview of Blockchain Technology: Architecture, Consensus, and Future Trends. 10.1109/BigDataCongress.2017.85. Zhu, H.; Zhou, Z.Z. (2016) Analysis and outlook of applications of blockchain technology to equity crowdfunding in China. Financial Innovation 2, 29. Doi:10.1186/s40854-016-0044-7 Zīle, Kaspars; Strazdiņa, Renāte. (2018) Blockchain Use Cases and Their Feasibility. Applied Computer Systems. 23. 12-20. 10.2478/acss-2018-0002.

99

Appendices

Appendix A - IPF Documents to be provided for the complete commercial property information package with regard to title/CPSEs. From IPF., 2012

100

101

102

103

104

Appendix B - Blockchain prototype A simple Blockchain with the concept of Proof-of-Work implemented in JavaScript.

const SHA256 = require("crypto-js/sha256");

class Block{ constructor(index, timestamp, data, previousHash = ''){ this.index = index; this.timestamp = timestamp; this.data = data; this.previousHash = previousHash; this.hash = this.calculateHash(); this.nonce = 0; }

calculateHash(){ return SHA256(this.index+this.previousHash+this.timestamp+JSON.stringify(this.data)+this.nonce).toS tring(); }

mineBlock(difficulty) { // Keep changing the nonce until the hash of our block starts with enough zero's. while (this.hash.substring(0, difficulty) !== Array(difficulty + 1).join("0")) { this.nonce++; this.hash = this.calculateHash(); }

console.log("BLOCK MINED: " + this.hash); } }

class BlockChain{ constructor(){ this.chain = [this.createGenesisBlock()]; this.difficulty = 3; }

createGenesisBlock(){ return new Block(0, "01/01/2000", "I am the Genesis Block!", "0"); }

getLatestBlock(){ return this.chain[this.chain.length-1]; }

addBlock(newBlock) { newBlock.previousHash = this.getLatestBlock().hash; newBlock.mineBlock(this.difficulty); this.chain.push(newBlock);

105

}

isChainValid() { for(let i = 1; i < this.chain.length; i++){ const currentBlock = this.chain[i]; const previousBlock = this.chain[i-1];

if(currentBlock.hash !== currentBlock.calculateHash()){ return false; }

if(currentBlock.previousHash !== previousBlock.hash){ return false; } } return true; } } let hunorChain = new BlockChain(); console.log('Mining block 1...'); hunorChain.addBlock(new Block(1, "20/07/2019", { amount: 4 })); console.log('Mining block 2...'); hunorChain.addBlock(new Block(2, "20/07/2019", { amount: 8 }));

106