Previously You have read about blockchain requirements and what it needs to build and implement a blockchain infrastructure. In this post, I will talk about the blockchain data structures. In fact, in order to create the best blockchain you need a data formats that is as simple as possible.

At this point, I have to make clear, we want to build blockchain applications. So the usage has to be as easy as possible. That is why we are going to use JSON all the way. JSON is human readable and even editable. However there is one problem to overcome. In JSON different indentation is allowed as well as the order of the properties in an object can change. This can become, as creating a signature or a hash of that data can produce different hashes. To overcome this obstacle, we are simple going to use the json-stable-stringify module. In other words, when serializing an object to JSON, we make sure, the properties are always sorted alphabetically and do not use any beautify and indentation.

The data structure, this is one part of the magic:

So here are the explanations one by one. previousHash: is to store the hash of the block before the current block. In the first block, the genesis block, this hash is just filled with a zero. The hash is generated via a algorithm such as MD5, SHA256, SHA512. Bitcoin uses SHA256, In the system I propose it will be SHA512. And you know why? Because we can. TimeStamp is clear, is supposed to be the current time when the block is created(when ever this is). Data is going to be the data, it can be a list of transactions, a list of function calls, a single transaction or function call, or just some arbitrary information to record, such as events. Signature is going to be the signature for the server that is maintaining this blockchain. It will sign previousHash, height, timestamp and data. Hash is going to be the new hash for this block.

Did you see that, there is no nonce field. That is because we don’t do mining. Mining is for resource waisters, and has much to little business value as to do it.

And here you have it, the block for an awesome blockchain.

Next time we are going to talk about consensus. I believe, this is where we are going to have the biggest different compared to all other todays blockchain systems, such as Quorum, Etherium, hyperledger Fabic, Sawtooth and Burrow.

Contents