I started building a DApp – these were my architectural difficulties
By: Marius Reimer
Tags: Software Architecture, Smart Contracts, Solidity, Blockchain, Ethereum

This part is not gonna be focused on coding details, but more on the question:

What should I think about when building a Decentralized Application from a business and architectural design perspective?

It’s gonna be based on my experience and facts. The blockchain ecosystem (and software engineering in general) is very fast growing and changes often. So by the time reading this, there could be no Ethereum blockchain anymore, the majority switched to a competitor or whatever. But I don’t think it will be that outdated in the near future.

What is a Blockchain?

Consider the following scenario:

Think about being in a group of art people where each person draws a picture. At the end of the course, you all want to put your drawings with your name on the wall to win a prize. The next day a jury is going to rate the pictures. And there you see that the name on your picture has been changed to some ‘Rick…’. You can’t prove that it’s yours anymore. Even though you won the million dollar first price…

In a centralized system, you would have an authority, like the jury, who would say ‘okay, show my your ID’ – so you can claim your price. But the problem is still that the name has been changed to someone else. The jury could have signed the drawing in the beginning, so that there is no chance of manipulation anymore. But, what if the jury itself is behind the manipulation? Or its system got hacked?

In the end you have to trust one authority to sign your drawing, which is fast and easy to do. Also, when the signing happened, has to be managed by this authority.

In a decentralized system, all artists of the group would have two random keys: One for the public and one for private, to keep just for yourself.

The idea is now to use this private key to sign your work so that only you, using your private key, can say that it’s you who created the drawing.

To be consent about what happened and in which happened, we need the concept of a blockchain:

Each person in the group must have a consent about what happened in the system. That means, that everything is noted publicly.

So when you want to sign your picture, you take, for example your Name and your private key together, to create a unique hash of your work. Using your publicly available key, now everyone can verify that it’s from you. But only you can proof that it’s your work.

Now, the problem comes that anyone could come to do that signing and submit something. And to where? Simply put the crypto signed drawing on the wall? – we need a publicly shared ledger.

Every time someone wants to publish a drawing, he or she needs to put a reference to the latest drawing and their hashed signitation together into a block, and then chain them together. Note: this is a very rough explanation of the whole process.

In reality, a new block can only be added to the blockchain if the mathematically problem has been solved (mining process). This means, that the miner, who solved the difficult problem, tells the group about the easily verifiable solution. For a miner to stay motivated in mining, there might be a block reward and fees.

What is a smart contract? – DApp

Smart contracts are ‘software codes’ that run on a blockchain. They are self-executing, means that there is no central authority necessary to run that software. In general you can do many different things on a blockchain — and currency, ownership or smart contracts are just a few examples of them. A DApp is a decentralized application, which runs partly or entirely on the blockchain.

So, back to the arts and drawing scenario. Let’s say you write a piece of software (smart contract), that handles the whole authority process:

A jury is deploying a smart contract so that the whole system can begin.

In order to add a drawing to the system, you have to pay a pre-defined fee, that is being added to a ‘pool’ in the contract.

Everyone can see who added a drawing to the system.

The jury can stop the ‘adding drawings’ process and then rate the drawings.

After the winner has been selected, each voting member gets their occured transaction fees back. Then the winner gets all the money from the pool and the smart contract is being deactivated.

An interesting part about that smart contract system is, that nobody can steal money, manipulate, hack or do whatever bad things.