BigchainDB, a database on blockchain steroids

Alfonso de la Rocha
Dec 7, 2018 · 6 min read
Image for post

A lot of people in the blockchain ecosystem may criticise, or even hate BigchainDB claiming that “it is not a real blockchain”, and they may be right, but neither is Hyperledger Fabric. From my honest opinion, BigchainDB it is a technology worth knowing, specially if you are planning to deploy decentralised or distributed systems in a corporate environment.

BigchainDB is an open source distributed storage system whose aim is to combine the main benefits of “traditional” NoSQL databases, with the benefits of blockchain technology (kind of like what AWS recently announced with QLDB — Quantum Ledger Database). One of the main benefits I see in BignchianDB is the ability of deploying a blockchain-like decentralised system using production-ready technologies. Let me explain myself, one of the main concerns of the deployment of blockchain systems in corporate environments is the current immaturity of the technology. But wait a miute, we are already deploying NoSQL databases in our current systems, right? and the fact that BigchainDB is based on a production-ready database makes it really appealing for its deployment in production without having to wait for the rest of blockchain platforms to catch up and be massively adopted by corporates.

Image for post
Image for post
BigchainDB shares the main benefits of blockchain technology and distributed databases.

BigchainDB is built from a federation of enterprise-ready database nodes, such as MongoDB instances, which store inmutable information about assets in a synchronised manner. Through the executing of Tendermint’s BFT consensus algorithm, the data stored in the network is spread and synchronised between all the nodes, assuring its integrity. In short, BigchainDB is a MongoDB database which uses Tendermint to obtain its blockchain features.

A BigchainDB network may be public, private or permissioned, according to the access permissions entities have over the system. In a public BigchainDB, any participant should be able to access the network or deploy their own MongoDB+Tendermint node and connect it to the database federation; while a permissioned BigchainDB could be managed by a consortium or a governing entity, where every member of the consortium manages its own node in the network, and no one can join without permission (analogous to what happens in the rest of permissioned blockchain technologies).

The basic information structure in BigchainDB are assets. Assets are “physically” represented as JSON documents in MobgoDB. These assets are owned by a user in the system, and he is the only one entitled to make changes over it. In order to create, transfer or modify an asset, a transaction have to be sent to the BigchainDB network. This will trigger Tendermint’s consensus algorithm, in charge of processing the transaction, validating it, synchronising all the nodes, and storing the corresponding changes over an asset in every MongoDB node of the network.

BigchainDB’s transaction model is analogous to the one Bitcoin, in the sense that an asset transaction receives and asset input which is then transformed to an output that may be used in the future as an input for new transaction. Asset outputs can only be used once as input of a transaction. There are two types of transactions in BigchainDB:

  • CREATE transactions generate a new asset in the system (as a JSON document in MongoDB) with two types of information in it: asset information, which is immutable and can’t be modified once the asset is created; and metadata, which can be modified through subsequent TRANSFER transactions.
  • TRANSFER transactions allow the transfer of ownership of an asset, or the modification of the metadata. The only one entitled to perform this transaction over an asset is its owner. These transactions use as input an unused output of the asset, generating as a result a new output with the corresponding modifications (changes in its ownership or metadata). As advanced above, an asset output can not be used twice as input of a transfer transaction.

BigchainDB assets may represent ANYTHING. From a bycicle, to a car, government bonds, tokens, intelectual property or a non-fungible asset.

After this brief overview you may be wondering, how can I start using BigchainDB? I want to check if it is worth of my attention or is it just a new useless project with no value in the blockchain ecosystem. The easiest way would be to go to BigchainDB’s official website and try the getting started section. This will post a message directly over BigchainDB’s testnet.

For the more experienced and adventurous (those who really want to understand the technology) I would suggest them to deploy their own BigchainDB network locally. If you have Docker and Docker Compose installed, this can be done easily by cloning BigchainDB’s github and executing themake run command. (If you prefer to run it in the background try make start).

git clone https://github.com/bigchaindb/bigchaindb.git
cd bigchaindb
make run

We have our BigchainDB up and ready, how can we create our first asset? I will show you how to do it using Nodejs (there are official drivers also in Java and Python). First thing’s first, let’s download the JS-driver npm install bigchaindb-driver.

Once our infrastructure and JS driver are ready, it is time to create a new identity in the system, and connect to the corresponding BigchainDB endpoint:

// Require JS driver
const
driver = require('bigchaindb-driver')

Our identity in the system is represented through a asymmetric key pair. As owner of the asset, we will use our private key to sign all of the asset transactions. To create a new asset we need to build a new transaction, sign it with our private key, and send it to the network so that Tendermint can do the rest of the work for us and create the asset:

// Create a new CREATE transaction (new output)
const
tx = driver.Transaction.makeCreateTransaction(

Once the transaction is validated, and the Tendermint round has finished, we should see the new asset in the network. If we are using our personal BigchainDB network, we will see how in our MongoDB node, a new asset magically appeared. Moreover, if in our network we have more than one BigchainDB instance (i.e. more than one node in the MongoDB federation), we should see how our new asset has been created and stored simultaneously in every node of the network.

If, on the other hand, we are using BigchainDB’s test network, we can use the driver to query the infrastructure to see if our asset has been created successfully as follows:

//Search asset
conn.searchAssets('My Asset').then(assets => console.log('Found assets with name My asset:', assets))

Finally, there you go with all the code for the asset creation (just for copy-paste purposes).

// Require JS driver
const
driver = require('bigchaindb-driver')

Easy, right? This was an introductory post, this is why I only guided you through a very simple CREATE transaction (I hate when posts get to extensive). In the following posts, we will go through TRANSFER transactions and more complex functionalities of BigchainDB. Nonetheless, if you just loved this technology and can wait for that moment to come, you can always go directly to BigchainDB’s documentation page for further details. And one last thing, are you curious to know what kind of project are being done with BigchainDB in the corporate world? Do not hesitate to follow me on Twitter or Linkedin to keep updated.

Get Best Software Deals Directly In Your Inbox

Image for post
Image for post
Image for post
Image for post
Click to read today’s top story

Coinmonks

Coinmonks is a non-profit Crypto educational publication.

Sign up for Coinmonks

By Coinmonks

A newsletter that brings you week's best crypto and blockchain stories and trending news directly in your inbox, by CoinCodeCap.com Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Alfonso de la Rocha

Written by

Research at Protocol Labs | Avid reader seeking for constant innovation. [https://twitter.com/adlrocha] [https://adlrocha.substack.com/subscribe]

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Alfonso de la Rocha

Written by

Research at Protocol Labs | Avid reader seeking for constant innovation. [https://twitter.com/adlrocha] [https://adlrocha.substack.com/subscribe]

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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