REAL ESTATE TRANSACTIONS USING BLOCKCHAIN TECHNOLOGY - DIVA
←
→
Page content transcription
If your browser does not render page correctly, please read the page content below
Umeå University Real Estate Transactions using Blockchain Technology Moa Hermansson A thesis submitted in fulfillment of the requirements for the degree of Master of Science in Engineering Specialisation: Interaction Technology and Design Supervisor Ulrik Söderström Examiner Thomas Mejtoft Department of Applied Physics and Electronics Fall 2019
Abstract Banking is considered only one of many industries that could benefit from using blockchain technology. A promising area in blockchain technology is so- called smart contracts, which is automated, decentralized and programmable contract solutions. Smart contracts can control the transfer of currencies or assets between parties under given conditions. The thesis work shows how blockchain technology could be applied to real estate transactions and minimize the need for third party involvement. The purpose of this paper is to provide an overview of the blockchain tech- nology and its possible applications in the real estate market. The focus was on exploring the process of real estate transactions and problems that could be resolved by using smart contracts and blockchain technology. With a qualitative research approach and a case study analysis, a proposition of a solution was made and discussed with its benefits and drawbacks. The goal was to in the process find the answers for the research questions such as: How can real estate transactions benefit from blockchain technology? What would it cost to store the necessary data on the main chain of Ethereum? How could blockchain technology be used for managing the transaction of the down payment? Even though a collaboration of systems and smart contracts could handle al- most every aspect of a real estate transaction, there are still legal boundaries to it being legally enforceable. The blockchain technology could contribute to more efficient and transparent systems compared to traditional centralized solutions. Keywords— Blockchain, smart contracts, real estate, decentralization, trans- parency, cryptography
Examensarbete Titel Bostadsköp med blockkedjeteknik Författare Moa Hermansson Institution Tillämpad fysik och elektronik Handledare Ulrik Söderström Nyckelord Blockkedja, Smarta kontrakt, Bostadsmarknad, kryptografi decentralisering, transparens Sammanfattning Den finansiella sektorn anses bara vara en av många branscher som skulle kunna dra nytta av att använda blockkedjeteknik. Ett lovande område är så kallade smarta kontrakt, som är automatiserade, decentraliserade och pro- grammerbara kontraktslösningar. Smarta kontrakt kan kontrollera överförin- gen av valutor eller tillgångar mellan parter och under givna villkor. Detta examensarbete vill visa hur blockkedjeteknik kan tillämpas på fastighet- stransaktioner och minimera behovet av att involvera en tredje part och samtidigt bidra till ett sätt att dela, på ett tillförlitligt sätt, historiken för bostadstransaktioner. Syftet med detta examensarbete var att ge en översikt över blockkedje- tekniken och dess möjliga tillämpningar på bostadssmarknaden. Fokuset låg på att utforska processen för bostadsstransaktioner och identifiera problem som skulle kunna lösas med hjälp av smarta kontrakt och blockkedjeteknik. Med en kvalitativ forskningsstrategi och en fallstudieanalys implementerades en möjlig lösning som sedan diskuterades med dess fördelar och nackdelar i åtanke. Målet var att i processen hitta svaren på forskningsfrågorna: Hur kan fastighetstransaktioner dra nytta av blockkedjeteknik? Vad skulle det kosta att lagra nödvändig information på Ethereums huvudkedja? Hur kan blockkedjeteknik användas för att hantera transaktionen av handpenningen? Säkerheten och potentiella risker så väl som kostnader och teknologins fram- tid diskuterades. I och med att smarta kontrakt består av kodade villkor kan det uppstå oförutsägbara sårbarheter, så systemet skulle behöva genomgå flera iterationer med testning innan det skulle kunna sättas ut i produk- tion. Även om ett samarbete mellan olika system och smarta kontrakt kan hantera nästan alla aspekter av en fastighetstransaktion, finns det fortfarande rättsliga gränser för om det kan uppfylla de formaliakrav som gäller för av- tal. Blockkedjetekniken kan bidra till att effektivisera och medföra till mer transparanta system jämfört med traditionella centraliserade lösningar.
Glossary Blockchain A distributed decentralized database monitored by a peer-to- peer network. 1 Deed of trust (real estate) In Swedish ’pantbrev’, creates as a security in- terest in the property for the lender. 19 Easements (real estate) In Swedish ’servitut’, nonpessessory right to use or enter a property without owning it. This could include the right to using a road on the neighbours property. 19 ECDSA Elliptic Curve Digital Signature Algorithm. ECDSA is used to generate keypairs. 9 Hash Cryptographic hashes are used to convert data to a fixed size which guarantees the data has not been changed. The hash is irreversible and unique. 5 Mining By solving difficult mathematical problems using hash functions to solve the Proof-Of-Work the miners are rewarded and are a part of confirming transactions on the blockchain. 6 Node A unit which functions as both a client and server to other nodes in the network. 4 Peer-to-peer network Non-hierarchical network distributed among sev- eral connected nodes. 12 Proof-Of-Work Hashing a block header over and over until the resulting hash fulfills the requirement set up by the network. These calculations require computing power and a certain amount of randomness. 7 i
RIPEMD RACE Integrity Primitives Evaluation Message Digest. A cryp- tographic hash function used in the Bitcoin standard. 11 Secp256k1 Standards for Efficient Cryptography. Refers to the parameters of the elliptic curve used in Bitcoin’s ECDSA algorithm. 9 SHA Secure Hashing Algorithm. Bitcoin and Ethereum uses SHA-256 to verify transactions and calculate Proof-Of-Work. 5, 11 Smart contracts "Cryptographic ’boxes’ that contain value and only un- lock it if certain conditions are met" [1]. 2 ii
Contents 1 Introduction 1 1.1 Collaboration . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 Theory 3 2.1 Blockchain technology . . . . . . . . . . . . . . . . . . . . . . 4 2.1.1 Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.1.2 Proof-of-Work . . . . . . . . . . . . . . . . . . . . . . . 7 2.2 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2.1 Public keys and private keys . . . . . . . . . . . . . . . 9 2.2.2 Cryptocurrency wallet . . . . . . . . . . . . . . . . . . 11 2.2.3 The blockchain network . . . . . . . . . . . . . . . . . 12 2.3 Ethereum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.3.1 Secure high-rate transactions . . . . . . . . . . . . . . 14 2.3.2 Smart contracts . . . . . . . . . . . . . . . . . . . . . . 16 2.4 Projects based on Ethereum blockchain . . . . . . . . . . . . . 17 2.5 Swedish real estate system . . . . . . . . . . . . . . . . . . . . 19 2.5.1 Specific requirements for apartments . . . . . . . . . . 19 2.5.2 Transferring the ownership of an apartment . . . . . . 19 3 Method 21 3.1 Research approach . . . . . . . . . . . . . . . . . . . . . . . . 21 3.2 Data gathering . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.3 Interviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.4 Implementation of the prototype . . . . . . . . . . . . . . . . . 23 3.4.1 Steps to create the system . . . . . . . . . . . . . . . . 23 3.5 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.5.1 MetaMask . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.5.2 Truffle . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 iii
3.5.3 IPFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 4 Result 26 4.1 Interview summaries . . . . . . . . . . . . . . . . . . . . . . . 26 4.2 Resulting prototype . . . . . . . . . . . . . . . . . . . . . . . . 27 4.3 Usage of the system . . . . . . . . . . . . . . . . . . . . . . . . 28 5 Discussion 30 5.1 Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 5.1.1 Benefits and drawbacks . . . . . . . . . . . . . . . . . . 30 Cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Technology . . . . . . . . . . . . . . . . . . . . . . . . 32 Risks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 6 Future work 34 7 Conclusion 35 iv
Chapter 1 Introduction We are living in the age of decentralization and the removal of middlemen. The digital era is slowly transforming and replacing traditional methods. One of the new technologies that have gained popularity over the last decade is decentralized digital currencies, also called cryptocurrency, stored in a Blockchain. Banking is considered only one of many industries that could benefit from using the technology of blockchain [2], and it is not limited to only trading currency. Tech giants such as IBM, Amazon, Google, and Facebook are jumping on the blockchain trend, and in 2019, businesses expect to spend $2.9B on the technology [3]. The benefit of this new technology is that it aims towards the decentraliza- tion and removal of third parties. It enables payments to be sent directly between parties without the need for a financial institution, such as a bank, to act as a middleman. The blockchain system is open-source and relies on cryptographic proof instead of trust [4]. The transparency of the blockchain technology could render the need for centralization obsolete. When selling a property, it is standard to hire a real estate broker. The broker provides consultation, advertisement, supervises transactions, and contracts. The fee for the real estate broker depends on the price of the property. The higher the value of a property usually means more expensive real estate broker fees. In Sweden, when selling a property, a real estate broker will charge about 1.5-5% of the final price of the property [5]. There are guides online that provides information on how to sell a property without a real estate broker. However, Fastighetsbyrån’s guide brings up several disadvantages of selling private, one of which is that the buyers are not going to find it as trustworthy as going through a broker [6]. 1
1.1. COLLABORATION The second-largest cryptocurrency by market cap is Ethereum (ETH) and got amounted to 19.14 billion U.S. dollars in the third quarter of 2019 [7]. Ethereum is an open-source and public blockchain featuring Smart contracts functionality. Smart contracts are electronic contracts that control the trans- fer of currencies or assets between parties under given conditions [8]. The terms of the agreement between the involved parties are implemented and verified by electronic signatures from the parties. The contract is added to the decentralized blockchain, and alteration can only be done by the par- ties involved. This technology could produce an innovative way to transfer property assets and payments between buyers and sellers in the Swedish real estate market. 1.1 Collaboration This thesis is written in collaboration with Nesta, a real estate platform that uses artificial intelligence to provide personalized results for properties and mortgage financing. 1.2 Goals In recent years the interest for blockchain technology has greatly increased. The opportunity to implement and profit from this technology has awaken curiosity among various businesses. The goal was to research different ap- proaches and implement a prototype, using blockchain technology and smart contracts, for handling real estate transactions on the Swedish real estate market. The goal was to in the process answer these questions. − How can real estate transactions benefit from blockchain technology? − What would it cost to store the necessary data on the main chain of Ethereum? − How could blockchain technology be used for managing the transaction of the down payment? − What are the boundaries, in the technology of blockchain, for making it unfit for managing real estate transactions? 1.3 Limitations The focus was on the technology and not the legality of the system. Moa Hermansson 2 February 6, 2020
Chapter 2 Theory The idea of digital currency and blockchain has been around for decades. One of the first concepts of decentralized digital currency was created in 1998 by Wei Dai, a computer engineer, who published an article suggesting an "anonymous, distributed electronic cash system"[9]. He called his cryp- tocurrency B-money. Dai proposed in his paper a fundamental framework for the currency and suggestions for how to resolve problems such as verification of ownership and the necessity for computational work to be done. Some of Dai’s ideas are a part of the solutions in the digital currencies used today [4]. About a decade later, in 2008, a person that goes under the pseudonym Satoshi Nakamoto published the paper “Bitcoin: A peer-to-peer electronic cash system” [4]. A decentralized digital currency was, for the first time, implemented in practice by Satoshi, and the solution united some ideas and concepts that have been previously suggested for such a system. In 2015, a new blockchain launched called Ethereum, with scripting func- tionality, which has a cryptocurrency called ether. Ethereum has a built-in Turing-complete programming language that allows users to write conditions, which need to be fulfilled, for a transaction to be made [1]. The first known Bitcoin transaction for a physical product took place on 22 May 2010. It started as a post on the forum BitcoinTalk [10], where a user made a post that he desired to exchange 10 000 BTC for two pizzas. Another user accepted and purchased the pizzas for him, and he then created the transaction of 10 000 BTC to him [11]. At that time, 10 000 BTC was estimated the value of 41 USD [10]. Today, as of October 2019, the pizza purchase has the evaluation of more than 80 000 000 USD [12]. 3
2.1. BLOCKCHAIN TECHNOLOGY 2.1 Blockchain technology Money is what the citizens in a society agree upon what money should be [13]. The value of money lies in the trust given by the society who uses it. The citizens have to trust that the Central bank is the exclusive distributor of new physical money. The clients of the banks need to lay their trust in that the bank stores the capital of which is transmitted. Unlike the systems implemented in society today the blockchain is decen- tralized, it does not have a centralized authority. With the technology of blockchain, the trust lies in that everything is transparent [4]. Blockchain technology comes with that each transaction is traceable and visible for ev- eryone who uses it. Each block holds several requested cryptocurrency transactions and is stored in a Blockchain [14, p. 15]. Each block carries information about the previous block in the chain, linking them together. There is a network of users that keeps a record of the blockchain and the requests for appending new blocks to it. The users, also called Nodes, are located all over the world and verifies and accepts new blocks [14, p. 147–148]. Because the blocks are linked, or based upon each other, it is possible to track every transaction ever made. The system prevents users from double-spending, for example, if user A has 1 cryptocurrency coin and creates two different transactions, of 1 coin each to two parties, B and C, both transactions will not be accepted by the network. Only the first to be verified of those two transactions will be accepted, the second will not. Before a block is added to the blockchain, the nodes check if all the transactions in that block are legitimate. Any currency in the requested transactions is traceable in already existing chain of blocks. Or as Satoshi put it, "In order to confirm the absence of a transaction is to be aware of all transactions" [4]. That is where the transparency of blockchain comes in. The trust is based on the visibility of all blocks and transactions ever made on the blockchain. Once a block is accepted by the network and added to the chain, it becomes immutable. 2.1.1 Block The first block on the Bitcoin blockchain is called the Genesis block and was created in 2009, it is the common ancestor to all blocks [15]. If you would follow any block backward, in a blockchain explorer, you would ultimately reach the Genesis block. When a brand-new block is requested to be added to the chain it has to Moa Hermansson 4 February 6, 2020
2.1. BLOCKCHAIN TECHNOLOGY match a predefined composition and must include specific data before it can be confirmed by the network. Since all the blocks are built upon each other, like a stack, each block has a block height. The Genesis block has block height 0 and, as of October 2019, the most recent block on Bitcoin has the block height 596 489. The Ethereum blockchain, as of October 2019, has a height of 8 617 293 blocks. Each block follows, as mentioned, a similar composition [14, p. 164–173]. Every block has a block header of which holds information regarding the block and transactions. In fig 2.1, is an overview of some of the information that is needed in a block. Figure 2.1: An overview of the data stored in each block on a blockchain The block height and the block hash is used as a block identifier, both of which are unique. The block Hash is created by the block header being hashed two times using SHA256 algorithm [4]. The previous block hash is the block hash that was added to the blockchain prior the current one. This creates a link between blocks, because the block N stores the N-1 block hash. The timestamp is the seconds from the Unix epoch when the miner started hashing the header (according to the miner). Nodes will not accept blocks with a timestamp that is more than two hours into the future. Moa Hermansson 5 February 6, 2020
2.1. BLOCKCHAIN TECHNOLOGY Nounce is an arbitrary number that miners change to modify the header hash. Merkle root hash is a summary of all the transactions in the block using a Merkle tree [4], also called a binary hash tree, the structure of a merkle tree can be seen in fig 2.2 It hashes each transaction with a double-SHA256, iterating through and combines them in pairs and hashes the transactions until it is only the root [14, p. 170–173]. Ha = SHA256(SHA256(Transaction a)) Hab = SHA256(SHA256(Ha + Hb )) Figure 2.2: Each transaction in a merkle tree is hashed in pairs to form the hash of the root. Given the merkle root, transactions can be proved that they are included in the Merkle tree hash. It makes for an efficient way of verifying the inclusion of transactions in blocks only using the Merkle root. Merkle root hash is only 32 bytes which are far more space-efficient than storing all the transactions. The first transaction in a block is a coinbase transaction. The coinbase creates brand-new Bitcoins and is paid as a reward to the miner [4]. The Mining reward has been decreasing over time, as a way of controlling inflation. Up until 2012 the coinbase reward was 50 BTC but got lowered to 25 BTC. In 2016 it decreased to 12.5 BTC. It is called The Bitcoin halving, because the reward is cut in half, and interval happens every 210 000 blocks [14, p. 187–189]. The next will happen on block 630 000 which is estimated to be mined in 2020. Moa Hermansson 6 February 6, 2020
2.1. BLOCKCHAIN TECHNOLOGY 2.1.2 Proof-of-Work Just like mining gold, mining cryptocurrency requires some work to be done. But instead of digging in the ground, cryptocurrency is mined by computing power. The Proof-Of-Work solves the problem of determining representa- tions in the decision-making process and maintaining the consensus of a network with many participants. It gave a solution for how to create a se- cure Byzantine-fault-tolerant consensus system [1]. The Byzantine Generals Problem states that a reliable computer system must be able to handle failure of one or more of its components. It comes from the classic abstract problem of which imagine several divisions of the Byzantine army are camped outside an enemy city, each division with its general [16]. The generals can only com- municate through messengers. They may only win if all the divisions attack at the same time. However, some of the generals may be traitors and try to throw off the plan. The generals must then have an algorithm to guarantee that a small number of traitors cannot cause the loyal generals to adopt a bad plan. The Proof-of-work in blockchain requires building and hashing a block header and changing the values of the parameters until it fulfills the proof of work. These calculations require computing power and it can take random amount of time to finish. As previously mentioned Bitcoin uses the hashing algorithm called SHA256 and the resulting hash, when applying this to a block header, it becomes the block hash. The work is done by changing the arbitrary value of the nonce (among other parameters) in the block header until a value is found that gives the block hash the required amount of zeros [4]. The first hash, presented below, is the genesis block (the first block ever created). Since the difficulty was much lower in the beginning, it does not contain, at the start of the hash, as many zeros as the block with the block height of 598 447. The Genesis block hash [15]: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f Block #598447 hash [17]: 000000000000000000038c853b5ba9c794b7b7af3dbdb0fe5165ca015a345850 The probability for a certain miner to be the first to find a block is pro- portional in relation to the miner’s processing power, and the processing power of the whole network. So in order to gain control of a blockchain, 51% of the processing power of the entire blockchain network is required [1]. This is also referred to as a 51% attack because it would make it possible Moa Hermansson 7 February 6, 2020
2.2. TRANSACTIONS for double-spending. In the whitepaper, Bitcoin: A Peer-to-Peer Electronic Cash System, Satoshi Nakamoto states "The system is secure as long as hon- est nodes collectively control more CPU power than any cooperating group of attacker nodes" [4]. For the miner who manages to solve the block hash requirement, they are rewarded with the coinbase and the transaction fees from all the transactions included in the block. The block reward for block #598447 was 12.5 BTC and transaction fees of 0.06965 BTC [17]. The miner was rewarded an estimated value, as of October 2019, of 107140 USD. There is a finite amount of Bitcoin. There are only 21 million Bitcoins that can be mined in total. As previously mentioned, the block reward halving occurs every 210 000 blocks. The following is the formula for the Bitcoin limit [18]. P32 8 i=0210000[ 50∗10 2i ] 108 As of October 2019, there are approximately 18 million Bitcoins in circulation which means 86% of all the Bitcoins that will ever be created, have been mined already. Even though proof-of-work solves the problem with consensus among dis- tributed peers, Bitcoin accounts for 0.35% of the entire world’s electricity consumption. The University of Cambridge published this data and their calculations are based on mining hardware and other parameters such as network hashrate [19]. 2.2 Transactions Cryptocurrency coins are transferred between parties by digitally signing a hash and include a public key and then adding a receiving public address and creating a transaction [4]. The coins can then be transferred again by the new owner by signing and adding another public key for the next owner, which creates a chain of ownership. A transaction can have several inputs and outputs. Transaction inputs can- not be divided, similar to currency notes. If you buy a cup of coffee that costs 5 US dollars and you hand over a 10 dollar bill, you will receive a 5 dollars bill back. Cryptocurrency works in a similar way. Let’s say user A wants to buy a cup of coffee for 0.015 BTC from B [14, p. 16–18]. User A Moa Hermansson 8 February 6, 2020
2.2. TRANSACTIONS uses a wallet system to create a transaction. User A has 0.1 BTC and cre- ates a transfer to B of 0.015 BTC, then signs the transaction, then a change of 0.0845 BTC is transferred back to A. The transaction requires a small transaction fee which in this case is 0.0005 BTC. The transaction is then put in a pool of unconfirmed transactions. When miners create new blocks they add unconfirmed transactions, from the unconfirmed transactions pool to the new block. The transaction fee is given to the miner, as a reward, who adds the transaction to the block. The miners’ priorities transactions based on the highest transaction fee. The higher the fee, the higher the reward for mining a block. That means if there is a high transaction fee, the transaction will be added to the blockchain faster and therefore verified faster. 2.2.1 Public keys and private keys Even though the blockchain and the transactions are transparent, the users can remain anonymous [4]. If for example, user A wants to start buying and selling Bitcoin, user A can generate several different addresses that can be used for sending and receiving currency. Before user A can receive money from user B, user A has to generate a private and a public key pair. Blockchain technology uses cryptography extensively. It is not used for en- cryption of transactions, instead, it is used for validation of ownership of funds by encrypting keys, addresses, and wallets. Keys in blockchain come in pairs, a public key and a private key. The public key is similar to a bank account number and the private key works as the pin code [14, p. 61–62]. So whoever has knowledge of the pin code, has control over the bank account. The cryptography for generating keypairs in Bitcoin uses a system called Elliptic Curve Digital Signature Algorithm (ECDSA) and Secp256k1 [20]. fig 2.3 shows an example of an elliptic curve. The system takes a small effort in computing time to generate a public key from a private one, but it is extremely difficult to reverse the process. In this case, decrypt a private key from a public key. The private key, k, should be generated by a secure source of entropy and could be any number between 1 and 2256 . The size of the private key space is tremendous. 2256 is approximately 1077 in decimal, and in comparison, the visible universe is estimated to contain 1080 atoms [14, p. 63–65]. Moa Hermansson 9 February 6, 2020
2.2. TRANSACTIONS Figure 2.3: Bitcoin uses the cryptographic system called ECDSA. This is the graph of the elliptic curve y 2 = x3 + 7 The private key, k, is multiplied by a predetermined point on the elliptic curve called generator point, G, which will produce the corresponding public key, K. K =k×G The public key is then defined as a point on the curve. K = (x, y) From the public key, an address is derived using cryptographic one-way hashing func- tions, making it more compact. The hashing algorithm output will generate a hash of 64 bytes independently from the size of the input, the output from using SHA256 will always result in a hash with 64 characters or 64 bytes. View the following example applying SHA256 to different lengths of strings: Input string: "Hello" (5 characters) SHA256 Hash: 185F8DB32271FE25F561A6FC938B2E264306EC304 EDA518007D1764826381969 (64 characters) Moa Hermansson 10 February 6, 2020
2.2. TRANSACTIONS Input string: "The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother’s keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon you. " (488 characters) [21] SHA256 Hash: E53927D1C61B337C38383E5F4CEC32BD15062C86 11417D48D889D5A5562DDE77 (64 characters) The hashing functions that are the most common in blockchain are called SHA256 and RIPEMD160. A = RIP EM D160(SHA256(K)) where K is the public key and A is the resulting Bitcoin address. The Bitcoin address is almost always encoded using Base58. It produces an address that is more compact and more readable because it excludes characters which could be challenging to differentiate between for humans such as 0, O, 1 and I [14, p. 63–74]. Bitcoin also has an additional security system for typos and a built-in error-checker in addresses. At the end of the Bitcoin address is a checksum added which can be used as a verification of that the address has been correctly typed. These security precautions, base58, and the checksum have been implemented into the system to make it easier for a human to read the public address from, let us say, a piece of paper. The user can then, from the piece of paper, correctly transcribe it into their wallet application and create a transaction. This minimizes the risk of users transferring currency to an incorrect address. If the transaction is completed and appended to a block on the blockchain, it is not possible to reverse it. 2.2.2 Cryptocurrency wallet To be able to make transactions on a blockchain it is common to use a wallet application. The wallet can manage the user’s money, keys, and addresses. In the first Bitcoin wallet, now called Bitcoin Core, it would generate private keys at random. This kind of wallet is called Non deterministic (Random) wallets. The user could generate new keys and addresses for every new transaction, which would require keeping a record of every private key. If the users create several transactions and store the assets in different addresses it would require creating back-ups frequently [14, p. 84–88]. Imagine having a large keychain were you need to keep track of a lot of unique and irreplaceable Moa Hermansson 11 February 6, 2020
2.2. TRANSACTIONS keys. If a private key is lost, there is no way to access the money connected to that address. Several new proposals to the Bitcoin have been formed over the years, the so-called Bitcoin Improvement Proposal (BIP). One of them is called BIP32 [22] which suggested a different procedure for wallets and managing keys, so-called deterministic wallet. Compared to a non deterministic wallet, a deterministic wallet creates numerous keys from a ’seed’, which makes the keys linked together in a tree structure [22]. A Bitcoin Improvement Proposal (BIP) called BIP39 [23] suggested using Mnemonic code or sentences instead of a random string used for private keys. BIP39 is used for the generation of deterministic wallets. It uses mnemonic codes, a collection of words, making it more manageable for users to write down and memorize without typing errors. Instead of saving the entropy, the user is only required to keep the Mnemonic sentence safe to be able to access the assets. See the following example generated by Mnemonic Code Converter [24]: Entropy: 27793f78112906b29f726445f0a39df3 Mnemonic: cherry size task car motor flock lava erode echo lunar trash trade This example is using 12 words, with 128 bits in total. From this ’seed’ of words a sequence of keys, of almost infinite depth, can be derived [14, p. 84– 88]. The length of the seed should be between 128 to 512 bits, where 256 bits are encouraged. If provided a public key, an attacker could not derive the private key more efficiently than by solving the EC discrete logarithm problem, which is as- sumed to require 2128 group operations [22]. 2.2.3 The blockchain network So far we have covered the issues of what blockchain, block, transactions, wallets, and keys are. To accomplish this decentralized distributed system, without a trusted party, a network of nodes is used [4]. This is made by com- puters that participate from across the world. As of October 2019, there are approximately 10,000 nodes on the Bitcoin network [25] and approximately 8,000 nodes on Ethereum network [26]. The network on the blockchain is Peer-to-peer network, or P2P, which implies that all the nodes that engage are of equal value. The network of nodes reaches a consensus by examining that new requested blocks contain a correct block header and transactions. The transactions need to be valid and after that, the new block is accepted Moa Hermansson 12 February 6, 2020
2.3. ETHEREUM to the blockchain. Users can join this network of nodes and participate in accepting new blocks. A "full node" in the blockchain network is a node that stores every block and every transaction. As of October 2019, the entire Bitcoin blockchain is approximately the size of 242 GB [27]. To run an Ethereum Full node, as of October 2019, it requires roughly 191 GB of space [28]. In Ethereum there is an additional kind of node which is called an Archive node. The Archive Node stores, not only, the entire Ethereum blockchain but as well as all of the historical states. Which in this case means all the balances of every account and states of the entire Ethereum ecosystem. The size of an Ethereum archive node is, as of October 2019, approximately 3.2 TB [29]. From a full node on Ethereum, you can calculate the states from the data in the full blockchain, the benefit from that is that it would go faster to retrieve that data from an archive node opposed to a full node. New blocks are added in an average block time on blockchain. If blocks are added faster than average, the difficulty of creating a block is raised. Bitcoin has the average block time of 10 minutes [4] and Ethereum has an average, as of October 2019, of 13 seconds in between blocks [30]. The system of Bitcoin adjusts the difficulty of creating blocks approximately every two weeks (or every 2016 block) so that it will maintain an average of ten minutes between new blocks [1]. If there is an increment of miners or if the miners have higher computing power the difficulty will go up. Making it less profitable to mine cryptocurrency. 2.3 Ethereum The Ethereum blockchain is similar, in many ways, to the Bitcoin blockchain. As mentioned previously one difference is Ethereum handles smart contracts. The code in the Ethereum contracts which is referred to as "Ethereum vir- tual machine code" can encode any computation including infinite loops. Contracts can call other contracts and potentially loop through recursion. This could lead to complications such as infinite loops crashing the system. This matter, which is known as the halting problem within Computer Sci- ence, demonstrates that it is impossible to know if a program will terminate [31]. The solution to this dilemma in Ethereum is the implementation of transaction fees, so-called gas. The implementation requires a transaction to have a maximum amount of computational steps it is permitted to take. Each transaction requested requires gas from the sender for processing the Moa Hermansson 13 February 6, 2020
2.3. ETHEREUM transaction request. The total transaction fee is calculated by transactionCost = gasU sed × gasP rice The gas price is often given in gwei. 108 gwei is equal to 0.1 ether (See table 2.1). Wei 10.000.000.000.000.000 Gwei 10.000.000 Ether 0.01 Table 2.1: A conversion between Wei, Gwei and Ether values. For example, an overview of the transaction made on 2019-09-11 in block number 8521808 [32]. It is a basic transaction from A to B, the fee is based on ’gas used by Transaction’ of 21 000 gas and ’gas price’ of 0.00000002 Ether which gives the transaction fee of 0.00042 Ether which is worth 0.08 US dollars (As of 2019-09-11) [32]. There are two kinds of accounts in Ethereum. The first one is external ac- counts which are controlled by a key pair of one public key and one private key, as previously mentioned in section 2.2.1. The other type of account is contract accounts, which are controlled by the code stored with the account. The address of the contract is determined at the time the contract was cre- ated. Every account has a balance of Ether which can be modified by sending or receiving transactions that include Ether. 2.3.1 Secure high-rate transactions It has been previously mentioned that the average block time in Bitcoin is 10 minutes and for Ethereum it is 13 seconds (see section The blockchain net- work). In Bitcoin, the network of miners keeps track of the longest-running chain and all other blocks get abandoned. The blocks that are not added to the main chain are called orphan blocks. A miner broadcasts to the network when it found a valid block and the network nodes, who receive it, accept the new block and start building the next block. The 10-minute interval allows blocks to be distributed to a majority of nodes before another block is created. If there is a tie in which miner finished the block first, the network will pick the longest-running chain. This means that the part of the network who adds a block on top of the block with a tie will be the longest-running chain. As time passes, all the nodes will adopt the same main chain. Moa Hermansson 14 February 6, 2020
2.3. ETHEREUM Imagine a shopper who wants to pay for a cup of coffee with Bitcoin and has to wait 10 minutes for the transaction to be valid. Then it is more efficient to pay with a bank card. Ethereum wanted faster transactions, but the longest- running chain algorithm is not scalable for more high-speed transaction rates. Because the network need to broadcast new blocks to a majority of nodes and reach a consensus and accept them before starting to build the next. If the transaction speed was set to higher, the odds that the miners would create a few blocks which never will be accepted would increase. So by increasing transactions speed it will be with the cost of reduced security with a high stale rate [1]. Stale rate refers to the rate of orphan blocks, blocks which never got added to the main chain. To solve this issue, Ethereum uses a modified version of the "Greedy Heaviest Observed Subtree" (GHOST) protocol [33]. Figure 2.4: A chain of blocks where the main chain is selected by GHOST. Red is an attacker chain. Blue blocks are so called uncle blocks. The heaviest subtree will be part of the main chain, so the blocks that are off the main chain can still contribute to the chain weight [33]. This way the stale blocks are included in calculation of which chain is the longest. The block which are stale or orphan are called uncle blocks in Ethereum, because they are not parent to a block but still part of the family tree [1]. Consider the block tree in fig 2.4, Block 1B is supported by blocks 2B, 2C and 2D. Moa Hermansson 15 February 6, 2020
2.3. ETHEREUM Block 2C is supported by 3C, 3D and 3E. Therefore, the red attacker chain will not be part of the main chain because the chain following 1B have more support from the network. Unlike orphan blocks in Bitcoin, the miner who produces a uncle block is given a reward. GHOST makes it possible to have a faster transaction rate compared to Bitcoin and still keep it secure, because a majority of nodes will receive a block and then start building on top of it. 2.3.2 Smart contracts Smart contracts are essentially programs which controls the behaviour of accounts within the Ethereum state. Anyone could deploy a smart contract, for a small fee, to the main chain of the Ethereum blockchain. Once a smart contract has been deployed, it cannot be edited. In Ethereum, in addition to that wallets has addresses, each contract has an address [34, p. 92]. Contracts can send and receive ether, just like wallets. In addition to ether, the transactions can also contain data about which function in the smart contract is called and data for the parameters. Contracts can create transactions and call other contracts. The smart contracts can be written using many different high-level languages [34, p. 39]. The most common one for implementing smart contracts are done in a object-oriented language called Solidity, which is specifically designed to target the Ethereum Virtual Machine (EVM) [35]. The EVM is the runtime environment for smart contracts and is completely isolated, which means that code running inside the EVM has no outside access. The virtual machine does not execute the contract language Solidity directly, instead the contract code is compiled to low-level machine instructions called opcodes, which each represents one low level operation [36]. The EVM is, similar to JVM (Java Virtual Machine) [37], a Stack Machine. Which means it follows the principle of LIFO (Last in First out). When com- piling a solidity contract the bytecode and opcode is viewable. For example it can look like this: Opcodes : "PUSH1 0 x80 PUSH1 0 x40 MSTORE" Bytecodes : "6080604052" This is the beginning of the smart contract bytecode and it is how the smart contract boots up. It is equal to the first line ’contract HelloWorld {’ of the following solidity smart contract snippet: Moa Hermansson 16 February 6, 2020
2.4. PROJECTS BASED ON ETHEREUM BLOCKCHAIN c o n t r a c t HelloWorld { f u n c t i o n h e l l o ( ) p u b l i c pure r e t u r n s ( s t r i n g memory ) { r e t u r n " H e l l o world " ; } } As previously mentioned, smart contracts costs gas to deploy and run. This was implemented to prevent smart contract code, with never ending loops, to potentially breaking the system. If a smart contract code has never ending loops, the code will run until it simply runs out of gas. Imagine gas in a car, the car will continue until it runs out of gas. The cost for a smart contract is calculated based on how many operations there are from start to finish. In the above opcode for initializing a a smart contract, it uses the codes PUSH1(0x60) and MSTORE(0x52) which each requires 3 gas to run [36]. The base cost of deploying a smart contract to the Ethereum blockchain is 32 000 gas. Deploying the simple smart contract ’HelloWorld’ above would cost around 122 000 gas (as of Dec 2019). Therefore, it is of utter importance to optimize the code of a smart contract to prevent from unnecessary costs. Storing data on Ethereum blockchain would cost a lot. Based on the Ethereum yellow paper storing one 32-byte word of data using the opcode ’SSTORE’ costs 20.000 in gas [36]. A kilobyte of data would be 640.000 gas. For example storing 10 KB of data with a common gas price of 10 Gwei would result in the calculation of 6,4m gas * 10 Gwei = 0.064 ETH which is roughly equal to 9.28 USD (as of Dec 2019) [38]. Unlike Bitcoin, which has a fixed block size of 1 MB, Ethereum’s block size varies. The size of a block is instead bound by how many units of gas can be spent for each block. This limit is called block gas limit and is visible in a block explorer. At time of writing, the average block gas limit is around 10 million gas, with an average block size between 20 to 30 KB. 2.4 Projects based on Ethereum blockchain In November of 2017, a smart contract with the name ’CryptoKitties’ was deployed to the Ethereum blockchain and the website CryptoKitties was launched. After about a month, In December the same year, CryptoKitties had 60k registered users and accounted for roughly 25% of Ethereum traffic alone. Moa Hermansson 17 February 6, 2020
2.4. PROJECTS BASED ON ETHEREUM BLOCKCHAIN CryptoKitties are digital, collectable cats (see fig 2.5) built on top of the Ethereum blockchain [39]. They can be bought and sold using ether, and bred to create new cats with different traits. Each cat is unique and two cats can produce an offspring with a genetic combination of the parents. Figure 2.5: A picture provided for press at CryptoKitties official website [40] CryptoKitties was the first game built using Ethereum smart contracts [39]. The goal of the developers behind CryptoKitties was to increase the knowl- edge and educate users about some of Ethereum’s features, and explore ways of creating decentralized applications using blockchain technology. The cats could be purchased through the browser extension Metamask, which is an easy to use wallet and able to connect to a variety of Ethereum nodes and local running blockchains [34, p. 39]. "Users were more comfortable buying and spending Ethereum in a context they found appealing." - Benny Giang, Founding Team Member of CryptoKitties [41] The CryptoKitties smart contract, with the length of 2013 lines, is visible on the Ethereum blockchain with the following address: "0x06012c8cf97BEaD5deAe237070F9587f8E7A266d" [42] and it han- dles ownership, breeding and transactions of cats. Each CryptoKitty is a non-fungible token following ERC#721, An Ethereum Improvement Pro- posal. Fungibility is a characteristic of an asset that determines if it can be exchanged for a similar asset that holds the same value. For example, a five dollar US bill can be exchanged for another five dollar US bill, because they hold the same value. Non-fungible means that each CryptoKitty is indivisible and unique. Moa Hermansson 18 February 6, 2020
2.5. SWEDISH REAL ESTATE SYSTEM 2.5 Swedish real estate system To be able to apply blockchain technology to the field of real estate, some background to how the system works is required. In Sweden, there is no requirement for a property sale to go through a real estate agency. A real estate agent can also be partly involved in the process, such as providing the contract or help with the evaluation of the property. An overview of necessary steps when selling a real estate is an evaluation of the property, submit documents, advertisement, provide showings of the real estate for potential buyers, bidding, write a contract, and finally sign the property deed and hand over the keys [43]. The documents related to the real estate should be provided such as floor plans, Deed of trust, and Easements. The assets of the property, such as fixed interior, is regulated by the Swedish Land Law Code (2 kap. 2 § Jordabalken) [44]. For transferring the ownership of real estate properties in Sweden, there are requirements which need to be fulfilled in order for the contracts to be valid. The conditions need to be fulfilled before the ownership can be transferred and verified. If not done correctly, the contracts could be invalid. 2.5.1 Specific requirements for apartments When purchasing an apartment in Sweden, you purchase the right to live in the apartment and a share in a housing cooperative. It is the tenant owners’ association that owns the apartment. The association is a coopera- tive legal entity which owns real estate, and each member holds a share in the association. Before the buyer can move in, they have to apply and be granted membership of the association. If the buyer is denied membership to the association, the legal contract of transferring the ownership is nullified, and the buyer cannot move into the apartment according to Swedish law for tenant-owned apartment (6 kap. 5 § Bostadsrättslagen) [45]. In November 2010, a nationwide apartment registry was finalized in Sweden [46]. Each apartment has a four-digit code combined with the address, mak- ing it unique. The first two numbers are the floor of the apartment, the last two are the placement of the apartment on the floor. 2.5.2 Transferring the ownership of an apartment In the law for a tenant-owned apartment ( 6 kap. 4 § Bostadsrättslagen) it states that the legal documents regarding the transfer of the ownership of a Moa Hermansson 19 February 6, 2020
2.5. SWEDISH REAL ESTATE SYSTEM residence requires it to be in writing and signed by both seller and buyer. The proof of purchase must contain details regarding the apartment in question and a agreed price. Not required by law, but should be included in the contract, is the date when the new owner is allowed access to the apartment — the date for the transfer and the amount of the down payment. When purchasing real estate, it is sometimes included in the contract conditions which needs to be fulfilled. For an apartment, it could be that the new owner has to gain membership in the tenant owners’ association for the ownership transfer to be valid. Moa Hermansson 20 February 6, 2020
Chapter 3 Method This chapter presents the used method to collect and utilize the information and design a prototype of which evaluation could be used to answer the research questions. The research problem, provided by the collaborative company Nesta, is how the Swedish real estate market, focusing on the process of real estate trans- actions, can benefit from using smart contracts and Blockchain technology. The tools that were used are explained in the section the construction of the prototype. 3.1 Research approach Two methodologies were chosen, using a combination of qualitative methods [47] and case study research [48]. The methods, using semi-structured in- terviews and observations, was selected because of the given situation of the study and the nature of the problem. A qualitative research approach aims to develop a deep understanding of a situation; in this case, the position for the homebuyers and sellers. Qualita- tive data is rather expressed in words than numbers [47]. With a combination of collected data through the interviews and research (see fig 3.1), the next step was to apply this on real-life scenarios. A case study analysis aims to investigate problems and different alternatives and propose a solution for solving a business problem [48]. The focus of a case study analysis is to identify fundamental problems and examine why 21
3.2. DATA GATHERING they exist. Through the research of all relevant aspects, propose a solution and discuss the benefits and drawbacks. Below (see fig 3.1) is an overview of the different method steps that was used, starting with background research. Literature review and interviews as well as analyzing data and developing the prototype and theory framework were done in parallel. The design of the prototype system was based on the data from the interviews and the theory. The evaluation of the results was based on the previous steps. Figure 3.1: An overview of the method steps starting with background research and ending with conclusions. 3.2 Data gathering In order to answer the research questions, relevant literature was explored. Looking into several real-world applications and their usage of blockchain was done to understand how blockchain technology has been applied to dif- ferent areas. Interviews and research were done to get an idea of the current situation and identify the issues related to real estate transactions. The literature was collected from different sources that could verify each other. The original white papers written by the creators behind blockchain systems Moa Hermansson 22 February 6, 2020
3.3. INTERVIEWS and official documentation of systems and the references from these papers were used as a point of reference. Information was collected from real estate platforms, real estate brokers websites and the Swedish law book to get an understanding of the real estate market in Sweden. Suitable tools for the smart contract application was researched. 3.3 Interviews The data was collected through semi-structured interviews with three differ- ent participants. The first interviewee was interviewed over phone and the second two was interviewed at the collaborating company’s workplace. All the interviews was done in October 2019. The participants were selected based on that they had experience with pur- chasing real estate or had knowledge of the process of buying real estate. The interviewees had some knowledge of blockchain, which was necessary for providing a meaningful discussion of potential uses. During the interviews, the participants were informed of how smart contracts works and Blockchain technology in general. The participant answered ques- tions regarding their experience of the real estate market and the process of purchasing properties. A discussion followed where the interviewees shared what they thought could be improved regarding the real estate market and potential benefits of applying new technologies to it. The length of the in- terviews was around 30 minutes long or longer. A summary of each meeting was made. 3.4 Implementation of the prototype From the data collected through the research and interviews a outline of the prototype was designed. The prototype that was built is a web application with a front-end built using React [49], javascript, and Web3 for interacting with Ethereum nodes. Truffle was added to the project to compile and deploy smart contracts. The smart contracts were implemented using Solidity [50]. For testing, a local Ethereum blockchain was set up using Ganache. 3.4.1 Steps to create the system Step 1: Identify potential functionality which could benefit the users Moa Hermansson 23 February 6, 2020
3.5. TOOLS Step 2: Identify conditions required to be fulfilled for the smart contract Step 3: Create a structure for the application Step 4: Implement application Step 5: Test and evaluate the system 3.5 Tools Throughout the research period of investigating similar applications on other fields, several tools were reoccurring in implementations of applications using Ethereum and smart contracts. So the following tools were looked into as being part of the prototype. Ethereum was chosen because information regarding the history of ownership transactions for the real estate can be made available for the next buyer. Public blockchains are difficult to tamper with, and once data is added to a block, it becomes immutable. This provides a verifiable and censorship- resistant option for transaction history to be open for the public. Ethereum was chosen because it has a lot of active nodes and is difficult to tamper with. 3.5.1 MetaMask This browser extension, briefly mentioned in subsection 2.4, is a wallet that runs in the browser and is used by, for example, CryptoKitties for the transactions in the application. Install it through their website https: //metamask.io. MetaMask will generate a wallet and show a mnemonic backup (see section 2.2.2) consisting of 12 English words. The default net- work on MetaMask is the Main Ethereum Network, but it gives the option to change to localhost, for example, a private test net using Ganache. 3.5.2 Truffle The most popular development framework for Ethereum [34, p. 15]. It has several features such as built-in smart contract compilation, deployment and testing. Part of the truffle suite is Ganache, a local Ethereum blockchain which can be used to deploy and interact with smart contracts [34, p. 52]. With automatic mining, the smart contracts and transactions are visible in a GUI after a few seconds. Moa Hermansson 24 February 6, 2020
3.5. TOOLS 3.5.3 IPFS The InterPlanetary File System (IPFS) is a peer-to-peer file system which is distributed among connected computing devices [51], inspired by the sys- tems Git and BitTorrent. IPFS uses a combination of technologies such as distributed hash tables (DHTs) and a BitTorrent inspired protocol. A hash table stores information as key/value pairs. IPFS, inspired by Git, has a generalized Merkle Directed Acyclic Graph, which is a data structure that can store versioned file systems. Similar to a blockchain, the nodes in IPFS do not need to trust each other. All content can be uniquely identified through its hash. The data cannot be tampered with because that would result in a different hash. Moa Hermansson 25 February 6, 2020
Chapter 4 Result In this chapter, the result of the data gathering and the construction of the prototype will be present. At the end of the chapter, there is a simple scenario of the system to give an idea of how it could be applied. 4.1 Interview summaries The first interviewee, who had experience with buying several real estates, had many ideas of how the system could be used. One suggestion was that it could be similar to what some real estate platform do with showing the history of sales for properties, but in a more decentralized way and providing more than just selling price. This system could be beneficial for potential buyers by having access to documents such as previous evaluations of the property. It could also provide data for the potential buyers to gain knowl- edge of the properties in the surrounding area. If by adding a third objective verifier, such as a real estate inspector in the smart contract, it could encour- age the buyer to hire an inspector and potentially find hidden defects. The second interviewee, who just bought his first apartment, suggested a system to minimize the need for a real estate broker and to do more of the work himself. That the real estate broker was only needed for the evalu- ation of the property and generating the written contract, with blockchain technology, it would provide decentralized real estate data that could not be tampered with by real estate platforms or brokers. The third interviewee, who was looking into buying an apartment, suggested that with the help of smart contracts, it would be easier for several people share the ownership of a property. It could also make owning a property 26
4.2. RESULTING PROTOTYPE less related to what social class one belongs. The interviewee expressed frustration that in the real estate market today, the buyer needs to have the money for the down payment as well as a mortgage approval, to be able to afford a home. 4.2 Resulting prototype The final prototype is a lightweight implementation of a system for real estate transaction between a seller and a buyer. It sets up and deploys a smart contract to a Ethereum blockchain and runs on top of the smart contract. Figure 4.1: An overview of the prototype construction Every user has a key pair, one public key and one private key. The keypair is created and distributed by the plugin metamask. When the smart contract is set up, it requires two public addresses, one for the seller and one for the buyer. Only these two addresses have permission to interact with the smart contract as a way of preventing outside interference. The required information is added to the smart contract. It contains details regarding the address and number of the property, information of the owner and buyer and the final price. The requirement of both parties signature, and validation of it, cannot be fulfilled. Therefore, the system provides an option for the user to store the written contract as a file as a safety precaution — Moa Hermansson 27 February 6, 2020
You can also read