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.
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.
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.
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.
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
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.
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(
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(
Transfer(msg.sender, _Buyer, _ID);
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)
To know how many properties the account has it’ll use this function
function getNoOfProperties(address __propertyHolder) public returns (uint)
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.