Decentralizing Real Estate

Walkthrough of a property transfer Dapp

Imagine spending all your life savings on a home for your family, one night you hear pounding on the doors, people demanding you evacuate the house immediately.

You purchased your property but don’t have the legal papers to back up your claim. For dozens of possible reasons; you either bought your house from someone who didn’t have them or faked them, you lost these papers, the agencies didn’t have the proper information or maybe you couldn’t afford the process.

This is a situation for thousands of people fear every day, according to the world bank, 70% of people don’t have legally registered land! In Rural Africa up to 90% of land is unregistered!

1/3 of countries don’t even digitally track land ownership! Imagine one of your biggest assets being stored somewhere in a filing cabinet. There’s not much stopping corrupt officials from tampering with your records or them getting destroyed in natural disasters.

This was the case in Haiti when dozens of government offices were left in ruins after the 2010 earthquake. To this day hundreds of farmers continue to battle to prove ownership of their land.

Places like Brazil don’t even have a government-based registration system instead, they have agent companies, Brazil alone has over 3,400 of them. These agencies severally lack coordination and communication. It is not uncommon to have a property with conflicting ownership.

Physical documents can take weeks to months to process with no guarantee they safely reach their destination or that they were forged.

If you’re already struggling to find your next meal, obtaining a land certificate can be a finical burden. On top of that, you can’t even take out a loan against your house as collateral.

The lost value of properties and resulting economic loss of opportunity is locking up a potential 10 trillion dollars.

Storing land digitally isn’t enough, there are hundreds of cases of governments or malicious officials tampering with property titles.

In Honduras the country’s database was hacked, bureaucrats were able to steal properties and place them under their own titles.

But what if we were able to detect suspicious behaviours like this in real-time while having a permanent and immutable record of property ownership. Stored on a network that’s nearly impossible to hack, tamper-proof and transparent so your ownership can’t be questioned?

That’s what’s possible with blockchain. Blockchains are like immutable ledgers, meaning the data can’t be changed once it’s on the ledger.

They’re distributed and decentralized, unlike our current centralized systems which have one central node and a bunch connecting to it. The problem with this setup is it only takes one point of failure for the system to become vulnerable.

Image for post
Image for post
Image for post
Image for post

In a decentralized system, all the nodes are interconnected, it takes multiple points of failure to become vulnerable. Every node on the network has a synchronized copy of this ledger, as changes are their ledgers automatically update.

Image for post
Image for post
Image for post
Image for post

This ledger is transparent because any of the nodes can audit the transactions on the ledger, but the transactors can stay anonymous through their public addresses. For a more in-depth explanation of the blockchain check out this article. Overall the blockchain is

  • Secure and backed up
  • Immutable and Tamperproof
  • Transparent and synchronized
  • Fast and relatively inexpensive

I replicated a decentralized application for transferring, registering and viewing land ownership using blockchain addresses on Ethereum.

Image for post
Image for post
Image for post
Image for post

Self-executing code: Smart contracts📝

A Decentralized application(Dapp) has a smart contract as it’s back end. Smart contracts are self-executing code that runs on the blockchain. Just like contracts in the real world, two or more parties have agreed-upon rules, when an event occurs it generates certain actions.

Smart contracts can be deployed on many blockchains but Ethereum is the biggest platform that’s specialized for deploying and interacting with these contracts.

Reading data from the blockchain is free but when interacting or deploying the contract, we need to pay gas. Gas just refers to Ethereums cryptocurrency Ether.

Every time we register or transfer a property it’ll cost us gas, but this fee is tiny. Compared to paper titles which with shipping can be costly for those living on less than a dollar a day(1 billion people).

Tool Kit for building 🧰

  • Metamask chrome extension wallet for making payments when interacting with the contract.
  • Remix IDE for writing, compiling and deploying smart contracts
  • Ropsten Ether Faucet to get free fake ether
  • Ethereum Ropsten Test Network, the network I deployed the contract to, it follows the same protocols as the main Ethereum network.
  • Web3 for connecting the smart contract to the front end

Smart Contact Walkthrough

We define our compiler version using pragma solidity^ and instantiate our contract.

pragma solidity ^0.4.0;contract MyPropertyContract
{

Create a property struct to hold some of the fields of our property

struct Property 
{
address ownerAddress;
string location;
uint cost;
uint ID;
}

We set the owner of the contract to whoever deployed it, in our case we’d want it to be the government. We create a counter to keep track of how many properties we have in our contract.

address public owner;uint public totalPropertyCounter;

function MyPropertyContract() public
{
owner = msg.sender;
totalPropertyCounterCounter = 0;
}

We want certain functions to be available only to the government so we create a modifier called isOwner. We initialize two events; one for registering a property and one for transferring it.

modifier isOwner
{
require(msg.sender == owner);
_;
}
event Register(address _owner, uint _ID);
event Transfer(address indexed _from, address indexed _to, uint _ID);

We link addresses their property structs through a mapping

mapping (address => property[]) public __properties;

We create a function for registering a property(only available to government) that takes in the details of the property as parameters and passes them as fields of the property struct. We increase the property counter and set the ID for that property at the counter.

We push the property to the government’s properties mapping and trigger the register event.

function registerproperty(string _location, uint _cost) public isOwner
{
totalPropertyCounter = totalPropertyCounter + 1;
property memory myproperty = property(
{
ownerAddress: msg.sender,
location: _location,
cost: _cost,
ID: totalPropertyCounter
});
__properties[msg.sender].push(myproperty);
Register(msg.sender, totalPropertyCounter);
}

A function for transferring our property, taking in the property ID and the address of the buyer. But before we do this we need to make sure the person owns the property by checking if it’s in their mapping.

Then we copy the property into the buyer’s properties mapping and delete it from the owners, then trigger the transfer event.

function transferProperty(address _Buyer, uint _ID) public returns (bool)
{
for(uint i=0; i < (__properties[msg.sender].length);i++)
{
if (__properties[msg.sender][i].ID == _ID)
{
property memory myproperty = property(
{
ownerAddress:_Buyer,
location: __properties[msg.sender][i].location,
cost: __properties[msg.sender][i].cost,
ID: _ID
});
__properties[_Buyer].push(myproperty);

delete __properties[msg.sender][i];
Transfer(msg.sender, _Buyer, _ID);
return true;
}
}
return false;
}

To view the property details of someone’s account, we go through the struct details of the property in the index of that account.

function getProperties(address _propertyHolder, uint _index) public returns (string, uint, address,uint)
{
return (__properties[_propertyHolder][_index].location,
__properties[_propertyHolder][_index].cost,
__properties[_propertyHolder][_index].ownerAddress,
__properties[_propertyHolder][_index].ID);

}

To know how many properties the account has it’ll use this function

function getNoOfProperties(address __propertyHolder) public returns (uint)
{
return __properties[_propertyHolder].length;
}

The blockchain alone doesn’t have much enforcement, but if governments began to implement these systems they could help create a stronger, more transparent and secure property registration system.

Helping people regain ownership of one of their most important assets, unlocking more economic opportunities and a better life.

Image for post
Image for post
Image for post
Image for post

Thanks for making it to the end, hope you enjoyed! Feel free to reach out on LinkedIn or subscribe to my newsletter to stay connected :)

Written by

Working to provide the world with secure control and autonomy over their identities through blockchain and personalized biometric linked vaults

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store