Technical Overview: the first real estate deal on the blockchain
There has been a lot of news coverage on the first historic real estate purchase via Smart Contracts: The Wall Street Journal, MSN, NewsWeek, New Scientist and many more published articles about it. Here I will share the technical details of the deal itself:
First of all, the deal was performed on the public Ethereum MainNet and can be inspected here: https://etherscan.io/address/0x7cdce8f97aff2f38a9c6a6c9f139998f7a79fa43. The full source code is also public and available in the official repo of Propy on the GitHub.
The process starts with the Propy iOS app, where the buyer chooses the property and reserves it by paying $5000. Then Propy deploys a deed smart contract for the chosen property into the Ethereum MainNet. It’s important to notice that different countries have different requirements to real estate transfers, so each country will have different deed smart contract to comply with local regulations. For the case of Ukraine we developed the contract to have property price, wallets of the parties, payment sequence, and Notary confirmation.
Propy performs ownership verification at the decentralized registry and generates a preliminary agreement, which has to be electronically signed by Seller, Buyer and Broker. The deed smart contract will change the property state to “Pending”
function sign(string _hash) returns(bool) {
if (selledId == msg.sender)
sellerSigned = true;
if (buyerId == msg.sender)
buyerSigned = true;
if (brokerId == msg.sender)
brokerSigned = true; if (sellerSigned && buyerSigned && brokerSigned) {
metaPA = _hash;
status = Status.payment;
StatusUpdate(status);
PropertyManager proeprtyManager =
PropertyManager(propyContractAddress);
assert(propertyManager.setPropertyToPendingState(propertyId));
}
updatedAt = now;
return true;
}
Once all parties signed the agreement buyer proceeds to make a payment in the address of the smart contract (using Ether — ETH, it could be Bitcoins).
function () payable {
require (msg.sender == buyer_wallet);
require (status == Status.payment);
PaymentReceived(msg.value, msg.sender);
if(this.balance>=price){
status = Status.paymentDone;
StatusUpdate(status);
}
}
After the payment is done the Notary makes another verification of the property ownership and transfer conditions in the Registry of Ownerships and Burdenings of Ukraine. If for whatever reason property cannot be transferred, the notary rejects the transfer, which clears the “Pending” state from the property and allows the buyer to withdraws the funds. If the Notary approves the transfer buyer and seller representatives sign the final agreement as required by Ukraine’s laws. The Notary sends the information of the deal electronically to the Registry of Ownerships of Ukraine, where the deed smart contract address was included (see the image below) and logins the Propy’s interface to check the transaction as signed and recorded. The sequence of this step is the Deed Smart Contract changes the status of the transaction as “Approved” in the Propy decentralized registry. The registry fee in PRO tokens is automatically transferred from the Buyer’s wallet.
function notaryActionApprove(string _date, string _localHash) {
require (agentId == msg.sender);
require (status == Status.paymentDone);
notaryActionDate = _date;
metaTDLocal = _localHash;
titleTransferStatus = TitleTransferStatus.approved;
uint256 companyComission =
comissionCalc.getCompanyComission(price);
uint256 networkGrowthComission =
comissionCalc.getNetworkGrowthComission(price);
require(propyToken.balanceOf(buyerId) >=
companyComission+networkGrowthComission);
assert (propyToken.transferFrom(buyerId,
propyCompanyWallet, companyComission));
assert (propyToken.transferFrom(buyerId,
propyNetworkGrowthPoolWallet, networkGrowthComission));
PropyComission(address(this), companyComission,
networkGrowthComission);
//updates the owner of the property
Property prop = Property(propertyId);
prop.approveOwnershipTransfer(buyerId);
status = Status.titleDeedAppoved;
StatusUpdate(status);
// release contract money to seller
pendingWithdrawals[seller_wallet] += this.balance;
status = Status.titleTransferDone;
StatusUpdate(status);
}
Property’s ownership now has been changed in both Propy’s Decentralized Registry and Registry of Ownership of Ukraine, so the electronic title deed with the blockchain hash and a QR code is sent to the buyer and the seller can withdraw the funds. It is important to notice that the title deed from the Registry of Ownerships of Ukraine contains Propy Deed Smart Contract address.
The transaction data is public and can be verified on the blockchain. There is a certain technical knowledge required to read the data from the blockchain, however we’re planning to build the Propy Blockchain Explorer (as per the whitepaper), which would allow to easily search and inspect the transactions.
We are already working on simplifying and automating some of the steps described above. With time, the integration between the registries will deepen and the number of steps reduced. This transaction is an incredible achievement and a solid step towards enabling peer to peer real estate transactions.