Learn more >
Yash Agrawal, Mithun Hallikerehundi, Thasmiya Noorain A N, Arun Sar, Srirama Sharma, Krishna Harsha Voora | Published February 8, 2019
Archived date: 2019-05-01
Supply chain management involves multiple business stakeholders who are distributed geographically. Large volumes of transactions are carried out between participants of supply chain and these transactions need to be traceable, immutable, reliable, shared, and run with a sense of trust.
These transactions currently use applications connecting different parties or interact offline through emails. But, this is inefficient as there is considerable delay from different parties to respond. With IBM® Blockchain technology, we can have these complex transactions run on a blockchain network and save them in a chain of blocks. As each transaction occurs, it is put in a block and each block is connected to one before and after it. Transactions are blocked together, creating an irreversible chain that is distributed, permissible, and secure. Hyperledger Fabric is emerging as the widely accepted standard for enterprise blockchain platforms. Through open source and open governance, it features innovative new capabilities hardened for use by businesses, ushering in a new era of trust, transparency, and accountability.
This tutorial discusses a use case from supply chain management and explains how business operations are run on a blockchain network by streamlining portions of ERP and thus eventually decrease the turnaround time. This tutorial can be used as a reference to solve similar problems and could be integrated with enterprise applications.
Oracle Database can run on IBM Power Systems™ as well as on IBM z Systems®. The IBM Blockchain Platform offers an IBM LinuxONE infrastructure option specifically optimized for blockchain and is integrated into IBM Cloud™ data centers. We have validated the stack on IBM Power Systems. To complete the steps in this tutorial, as a prerequisite, you need access to the following hardware and software:
This section briefs a scenario with the following problem:
When a purchase order (PO) is created by a retailer, the PO could contain multiple items with different quantities for different suppliers.
If the requested quantity or item is not available, the supplier contacts the retailer offline and the retailer updates the PO accordingly.
The following solution using Hyperledger Fabric has been proposed for the problem:
Figure 1. Architecture diagram
The architecture diagram in Figure 1 depicts the integration of business applications with an enterprise database such as Oracle Database, interacting with IBM Blockchain. The blockchain application (for example, Hyperledger Composer REST Server) help in communicating with the underlying Hyperledger Fabric and thus data flow happens between the blockchain application, enterprise databases, and Hyperledger Fabric.
Figure 2. Dataflow diagram
Let’s look at the various components and modules involved in this exercise.
cx_Oracle is a Python extension module that can be used to enable access to Oracle Database. The recent version of cx_Oracle is 6 and has been tested to work with Python versions 2.7 and 3.4. cx_Oracle can be used with Oracle Database 11.2, 12.1, and 12.2 libraries.
node-oracledb is an add-on for Node.js that allows high performance Oracle Database applications that are developed using Node.js and Python. The node-oracledb driver connects to an Oracle Database for fast and functional applications.
Peers are a fundamental element of the network because they host ledgers and smart contracts.
Orderer form ordering service is a communication medium that assures delivery of messages.
Fabric CA is a certificate authority (CA) for Hyperledger Fabric. It allows registration of identities, issuance of enrollment certificates (ECerts), certificate renewal, and revocation.
Smart contract or Chaincode helps in encapsulating the business logic. In our case, this represents the rules and regulations on which retailers and suppliers would interact.
Composer is an application development framework that simplifies and expedites the creation of Hyperledger Fabric blockchain applications.
Retailer can interact with the enterprise application as a supply chain application for managing purchase orders, stores, inventory, and warehouses. For this demo, we considered order management system, which is part of the supply chain application. Node oracledb modules provide connectivity from the node application to the Oracle Database. After an entry is made in the Oracle Database, a database change notification will trigger an event which is captured by cx-oracle. cx-oracle will publish the event to the Composer REST Server which allows interaction with Hyperledger Fabric through Composer APIs.
Suppliers can interact and accept or reject the purchase order from a supplier using the blockchain application.
After the suppliers enter the quantity and submit a transaction, the respective transaction is validated against the smart contract and the result is captured through cx_oracle from Composer REST Server back to Oracle Database.
This section describes the steps to install Oracle Database and Hyperledger Fabric and thus setup supplier retailer application.
Install Oracle Database 12.2 on AIX 7.2 as per the instructions provided at the following URL https://docs.oracle.com/en/database/oracle/oracle-database/12.2/axdbi/index.html
After the Oracle Database is up and running, checkout the Oracle Database scripts at the following URL to create schema https://github.com/harsha544/supplier-retailer-app/tree/master/oracle_tables
After setting up the Oracle environment using the PATH, ORACLE_HOME, and ORACLE_SID environment variables, invoke SQL Plus using the sqlplus command.
$ sqlplus user/user@dbname
Execute the wrapper.sql command to create the Oracle Database objects
You need to install node-oracledb and cx_Oracle for Node.js and Python applications respectively running on Linux on Power Systems to access the Oracle Database. Refer to the following URL for detailed instructions:
This section provides the steps to install and configure Hyperledger Fabric on Ubuntu 16.04 LTS ppc64le.
To install nvm, run the following command:
`$` curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
`$` wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
To install Python 2.X on Ubuntu, run the following command:
`$` apt install python2.7
Note: Ensure you have following version of Docker and Docker Compose:
Refer to the steps at the following URL to bootstrap the blockchain network:
In this section you will install dependent npm modules and start UI services through the Node.js server that invokes the retailer as well as the supplier UI through a set of REST services.
Start the retailer UI.
`$` cd $HOME/supplier-retailer-app/UI/Retailer_UI
$ npm install
$ nohup node server.js 2>&1 &
On successful completion, you can access the retailer UI at http://IPADDR:8082/.
Figure 3. Home page
Start the supplier UI
'$' cd $HOME/supplier-retailer-app/UI/Supplier_UI
$ npm install
$ nohup node server.js 2>&1 &
On successful completion, you can access the supplier UI at http://IPADDR:8083/.
In section we will see how to raise a new purchase order in the system. (the PO number will be autogenerated). Users can choose from pre-populated item lists and click Add to add items to the purchase order. Users must enter the item quantity against each item in the form. Based on the quantity and price of each item State Goods and Services Tax (SGST) and Central Goods and Services Tax (CGST) along with total value gets auto populated in the PO value of the page.
Upon submission, the PO along with the item details such as item ID and quantity will be sent to the Blockchain network. The suppliers in the blockchain network will now bid the quantity against each item which they could supply and send their response back to the application. If all of the items could be supplied by the suppliers in the blockchain network, the status of the purchase order will be Approved. If all the items in the request could not be supplied by the suppliers in the blockchain network, then the status of the purchase order will be Rejected along with the comments from the blockchain network on how the modification must be done so that the purchase order gets approved.
Figure 4. Creating a new purchase order
After generating the PO successfully, suppliers will now bid the quantity that they can supply against each item in the PO. To do so, access the supplier UI at https://IPADDR:8083.
Figure 5. Supplier home page
You can switch between the suppliers (for example, Nike/Adidas/Reebok) who are the participants of this blockchain network and specify the quantities to be supplied and click submit.
After recording the response from each supplier over the blockchain network, the PO gets evaluated and the quantity to be supplied for each supplier is shown (refer to Figure 6).
Figure 6. Approved quantities
The Search Purchase Order page is used to search an existing PO. User can enter the PO number and click search. The PO will be displayed on the page along with the Total tax, PO Value and Status fields of the PO.
Figure 7. Searching a purchase order
The application discussed in this tutorial can be used as a reference to identify, implement, and integrate a functionality within an enterprise software with IBM Blockchain.
You can use the cx_oracle and node-oracledb modules to integrate Node.js and Python modules with Oracle Database. This application demonstrates the use of IBM Blockchain not only in the banking industry but in other sectors and domains as well.
The IBM Developer podcast is the place where developers hear all about open topics and technologies.
July 22, 2019
Get the Code »
Back to top