A simple layer enabling a smart contract based web app

Michael Dietz
blockimmo
Published in
5 min readApr 24, 2018

In a previous post I introduced the core/foundational layer of blockimmo — our smart contracts. Mission-critical state and functionality live on-chain, encapsulated by these contracts. The rights/ownership to a plot of land is an example of on-chain state. The exchange/transfer of these rights/ownership is an example of on-chain functionality.

Our approach is to integrate seamlessly with the existing processes and systems powering the Swiss real-estate market, offloading bottlenecks/critical components on-chain. Playing to its strengths, while simplifying and streamlining where most effective, to enable a more efficient and robust market.

This post focuses on the interface between our contracts (living on the Ethereum blockchain) and our frontend/users. This layer enables easy, secure blockchain interaction, and seamless integration with our frontend. The result is an intuitive UI/UX for our users to buy, sell, and invest in Swiss 🇨🇭 real-estate.

blockimmo platform — the 3 major layers

Our general user should not care about blockchain, or any other parts of our software stack. In the same way nobody cares about what happens under-the-hood when they do an online bank transaction. We aim to facilitate the interaction between our users and smart contracts at a reasonable level of abstraction.

With a browser, the power of the internet is at a user’s fingertips. With a ÐApp, blockchain is. From here only a very basic understanding of the technology is required (i.e. web addresses in the internet world, public addresses in the blockchain world, and a few other concepts). Both the internet and blockchain user must always take caution though. And since blockchain users haven’t built an intuition for safety yet, we need to hold their hand a bit to ensure they don’t stray off the beaten path.

A first-principles approach to state

Only the most fundamental state is stored on-chain. One such example is a property’s E-Grid (Eidgenössische Grundstücksidentifikation — a universally unique identifier). By storing this (immutable) state, we can retrieve any other information related to a property dynamically/lazily (instead of explicitly maintaining/storing it) through existing, standard systems. This (functional) approach greatly simplifies and leads to a more resilient, robust platform. The end result is a smooth user-experience.

Calls (reads) vs. transactions (writes)

We aim to facilitate the interaction between our users and smart contracts at a reasonable level of abstraction.

Users interact with our smart contracts in two ways: performing calls (reads) and transactions (writes). Calls are cheap, instant, and completely abstracted from the user — they happen in the background without any user intervention required. Just like reading from any normal database. By establishing a connection to a public Ethereum node (i.e. via the Infura API) a client isn’t required to run a node themselves.

Transactions are expensive — they must be signed by the user with their private key(s), and then mined by the network (slow). This has two major implications: (1) blockimmo must provide users with an easy, secure way to sign transactions, and (2) these operations should be performed only when absolutely necessary.

Our first-principles approach to state puts us in a good position for (2). Because only the most fundamental state is stored on-chain, transactions occur rarely and are only performed when a user lists a property for-sale, or buys/invests. This small surface area allows us to really focus on an intuitive UI/UX around these processes to ensure the user fully understands what is being signed and complete transparency.

This leads us to (1). Instead of reinventing the wheel we rely on MetaMask — probably the most solid, well-tested solution enabling our users to review and sign blockchain transactions in-app.

Transactions are the weak link in the chain when it comes to building a secure ÐApp. While blockchains have been proven to be extremely secure, and we can develop secure, audited smart contracts, if an attacker tricks a user into signing a spoofed transaction (i.e. sending funds to a different address), or steals a user’s private key(s), all this security doesn’t matter. It is our job to make these kind of attacks as difficult/impractical as possible. Making transactions end-to-end secure is the major driving factor in our approaches to (1) and (2).

MetaMask

https://metamask.io/

We’ve identified MetaMask as the best default wallet for reviewing and signing transactions in-app. Users are not required to install the MetaMask Chrome/Firefox extension for browsing (performing calls/read-only) or buying/investing (optional here as explained in the coming sections). MetaMask is only required when listing a property for-sale . During this process we tokenize the property and deploy the smart contracts around/attached to it (i.e. the ShareholderDAO and TokenSale), and MetaMask integrates best with our UI/UX to make this process easy and intuitive for the seller.

It is important to note that MetaMask is a hot wallet — it lives on an internet connected device. If an attacker has full access to a user’s computer and MetaMask (either unlocked or the attacker also has the user’s vault’s password) then that user would be compromised. However, a TokenizedProperty has no real value until it is verified in the LandRegistry by blockimmo. If anything goes wrong up until this point, the entire listing process can be reverted without harm. This ensures a safe, fool-proof listing process for sellers, and guarantees a property’s legitimacy for buyers/investors.

Once a TokenSale is live, blockimmo has verified the TokenizedProperty in the LandRegistry. An attacker would gain nothing from having access to a seller’s private keys (used to list the property) at this point. This is because when configuring a TokenSale, the seller provides a public address (hardware wallet recommended) where raised funds (and/or any unsold tokens) are transferred upon completion of the TokenSale. This wallet is verified to be in the seller’s control by blockimmo in the listing’s verification process.

Wallet agnostic — hardware wallets supported and encouraged

Investing in a property (buying tokens via a TokenSale) is simply sending ETH to the TokenSale smart contract in exchange for tokens of the property. This is easily accomplished in-app via MetaMask, or out-of-band via any software/hardware wallet.

When exchanging value (verified tokens of property and/or ETH) we recommend using hardware wallets. We developed our smart contracts from the ground-up to enable seamless use of hardware wallets. In the near-future hardware wallets will be supported in MetaMask and our solution will become even simpler!

An intro to our web-app

So far we’ve introduced our smart contracts and how we interact with them. In our next post we will tie everything together to introduce our web-app!

--

--