June 2, 2020

Oracle Blockchain Quick Start Guide - Global available links

This book "Oracle Blockchain Quick Start Guide" systematically takes you through distributed ledger technology, blockchain, and Hyperledger Fabric while also helping you understand the significance of Blockchain-as-a-Service (BaaS).

This book is available globally now in multiple channels. Below are a few of them.

September 17, 2019

Oracle Blockchain Quick Start Guide

Want to start learning Blockchain and be comfortable in building an enterprise blockchain solution using the Oracle Blockchain Platform? Hope this book "Oracle Blockchain Quick Start Guide - A practical approach to implementing blockchain in your enterprise" (Authored by Vivek Acharya, Nimesh Prakash, and Me, published by Packt) would help you.

This book is intended to become a quick reference to learn Blockchain, Hyperledger Fabric, Design strategies, and build chaincode on the Oracle Blockchain Platform.

This book covers,
  • Exploring Blockchain and Blockchain-as-a-service (BaaS)
  • Construing Distributed Ledger Tech and Blockchain
  • Delving into Hyperledger Fabric
  • Engage in Business Case on Blockchain platform
  • Manage Solutions on Oracle Blockchain Platform
  • Developing Solutions on Oracle Blockchain Platform
For the convenience of beginners and developers, this book also provides all the code samples to download and execute.

The book is Globally available on Packt, Amazon, Google, and Kobo.

Oracle Blockchain Quick Start Guide

July 23, 2019

Invoking/executing rich query in Oracle Blockchain Platform (OBP)

[OBP] This example is developed in NodeJS.

Hyperledger blockchain ledger is storing data in Key-Value pairs. So, if to fetch the data from the ledger, we will pass the key. But do you know, we can query the ledger without the key aswell.
Hyperledger blockchain is providing an option to query the ledger using a rich query. ChaincodeStub class has a method getQueryResult() which does this job. Please note that this method is supported only for state databases that support rich query. Below is the syntax of the method.

    <async> getQueryResult(query)

   A query string is in the native syntax of the underlying state database

   Promise for StateQueryIterator Object

Below is the node JS code snippet to see the implementation of this method. In the below example, I am taking a product id from a user and fetching the set of keys and their JSON objects from the state database where the JSON object contains the given product id.

        let queryString = "SELECT key, valueJson FROM <STATE> WHERE json_extract(valueJson, '$.productid') = '" + args[0] + "'";
        let resultsIterator = await stub.getQueryResult(queryString);
        let results = [];

        while (true) {
            let oneRecord = {};
            let res = await resultsIterator.next();
            if (res.value && res.value.value.toString()) {
                let val = res.value.value.toString('utf8');
                try {
                    oneRecord.value = JSON.parse(val);
                } catch (err) {
                    oneRecord.value = val;
            if (res.done) {
                await resultsIterator.close();
                return Buffer.from(JSON.stringify(results));

In the above example, the getQueryResult()  returns a promise object with an iterator. Hence, we need to call next() method of it to get the inside values.