Setup The Blockchain Database

Posted By : Ankit Rai | 13-Jan-2021

BigchainDB — The Blockchain Database

 

 

BigchainDB is a scalable and distributed database for Blockchain. Bigchain DB enables enterprises to deploy applications with Blockchain and Proof-of-Concept.

 

The combination of NoSQL database with Blockchain DB is one of its primary benefits. In BigchainDB, Data is represented as an “asset”. Any physical or digital object structured as JSON and key-values can be an "asset" or data in BigchainDB.


Let us have a look at the list of components that are required to set up Blockchain DB


1.MongoDB

MongoDB is the distributed database that will possess the Bigchaindb as a collection. You can run it on localhost or add an IP in the MongoDB config file to run it on a particular host IP.

 

Also Read: The Advantages of MongoDB Over Relational Database


2. Tendermint

Tendermint contains a genesis.json file. This file has the id and key pair for all the members on the network. To create a peer-to-peer connection, a minimum of 4 nodes are a must.


3. BigchainDB

The setup can be performed using docker-all-one install

 

  1. docker pull bigchaindb/bigchaindb:all-in-one
  2. docker run \
      --detach \
      --name bigchaindb \
      --publish 9984:9984 \
      --publish 9985:9985 \
      --publish 27017:27017 \
      --publish 26657:26657 \
      --volume $HOME/bigchaindb_docker/mongodb/data/db:/data/db \
      --volume $HOME/bigchaindb_docker/mongodb/data/configdb:/data/configdb \
      --volume $HOME/bigchaindb_docker/tendermint:/tendermint \
      bigchaindb/bigchaindb:all-in-one

 

After proper configuration and start of the setup, we need to examine the DB:

 

On CLI, run command “mongo”

  • root@2de56a6c3953:/# mongo

          MongoDB shell version v3.6.17

  • show dbs
    admin     0.000GB
    bigchain  0.001GB
    config    0.000GB
    local     0.000GB

 

  • use bigchain

           switched to DB bigchain
 

  • show collections
    abci_chains
    assets
    blocks
    elections
    metadata
    pre_commit
    transactions
    utxos
    validators

 

Post setup,  any transaction we perform at any time will be reflected in bigchain DB under assets, blocks, metadata, and transactions collections.

 

CREATE Transaction

asset collection
{
"_id":ObjectId("b6871ab9fa5b17b9fe67b6804"),
"inputs":[…],
"outputs":[…],
"operation":"CREATE",
"version":"2.0",
"id":"7a1e4dd7…851ac5624"
}

metadata collection

{
"_id":ObjectId("ba24b9fe6ce86182667b3861"),
"data":{
"type":"Bike",
"name":"hayabusha"
},
"id":"a69002ef8740…45869951c48"
}

TRANSFER Transaction

asset collection

{

“_id":ObjectId("9a86b1gaa7g83310197a1413"),
"inputs":[…],
"outputs":[…],
"operation":"TRANSFER",
"asset":{
"id":"816c4dd7ae…51af1629"
},
"version":"2.0",
"id":"985ee697d…a3296b9"
}

metadata collection

{
"_id":ObjectId("16a32a119ce184120511a714c"),
"metadata":{
"transfer_time":9158568252
},
"id":"12sqa146a…av3weda3"
}

 

Choose Oodles For SaaS App Development Services

 

We are a 360-degree software development company that provides cross-platform SaaS app development services to address varied software project requirements. We have an experienced team of Java, PHP, and Python developers who use advanced frameworks, tools, and SDKs to build scalable web and mobile applications with custom features. For more detail, reach us out at info@oodlestechnologies.com.

About Author

Author Image
Ankit Rai

He is a dynamic Devops Engineer having good knowledge of AWS, Jenkins, Python, GIT, BASH, Docker, and Cloud Security

Request for Proposal

Name is required

Comment is required

Sending message..