This blog post is an article from a series of articles on the book published in December 2019 “Blockchain with SAP” (Rheinwerk publishing, Bonn, ISBN 978-3-8362-6914-8). This blog post concerns the eighth chapter of the book, which develops two example applications for MultiChain.
MultiChain is a descendant of the Bitcoin software, extended with functions for operation in private networks. Specifically, this is implemented through encryption to protect the participants’ communication.
The SAP Cloud platform supports MultiChain 1.0 and the new version 2.0. Version 1.0 does not support any smart contracts – MultiChain is therefore only a distributed ledger without the possibility for automation and programming. Only version 2.0 introduced smart filters – just another word for smart contracts. The programming language for it is JavaScript. MultiChain offers support for assets which can be managed in their own streams.
No smart contracts?
Without blockchain programmability, it prompts the question of configurability of separate applications – how are dezentralized applications developed for MultiChain?
The answer is RPC, or Remote Procedure Calls. The SAP Cloud platform offers a Swagger interface in the SAP Business Hub that allows you to configure your MultiChain entity via http calls. For this to work, you need to have your own MultiChain node provisioned and a service key created for it. You use this information to log in to the API page and set up a working environment (“Configure environments”), stating the new service keys. It would look something like this:
The screenshot on the left lists the two categories RPC (remote procedure calls) and Availability – the calls of the first category configure the MultiChain blockchain and the second category shows the general availability (“heartbeat”) of the node.
Pharmaceutical inventory
An initial basic application for the inventory of drugs is developed with MultiChain, analogous to the Hyperledger telephone book example from one of the previous blog posts. A single drug is labeled with its properties such as name, ID, date of manufacture, and so on – this must be recorded in the blockchain.
To do this, a separate stream must first be defined for a MultiChain blockchain – a separate data container for storing our drugs. Key-value pairs can in turn be assigned to this stream. The idea behind this is to store our drugs as JSON objects by stating a unique key in the blockchain.
Using the MultiChain API for version 1.0 sets up the stream – for this, a name needs to be assigned, “DemoStream” in this screenshot.
After a successful call, the blockchain is successfully configured and individual drugs can be written into the stream. This, too, happens by way of a special RPC call of the “publish” method.
SAPUI5 Frontend
After the backend has been successfully developed, a corresponding frontend can now be developed for it. The following screenshot shows the finished interface for the MultiChain pharmaceutical inventory.
The interface enables new products to be simply added, their availability edited and it lists all recorded products. It has been developed in the SAP web IDE and implements the general operations such as the saving of new drugs and the readout of available drugs in JavaScript. To do this, the frontend directly sends RPC calls to the MultiChain blockchain and receives the results for this which are in turn shown in the frontend. When writing, a new drug is written as a JSON object from the interface to the blockchain. The other way around, the interface can also send a read call via AJAX call to the blockchain in order to query all saved drugs.
More articles of this series can be found here:
- Blockchain with SAP: What is Blockchain and How Does It Work?
- Blockchain with SAP: Blockchain-as-a-Service Products from the SAP Cloud Platform
- Blockchain with SAP: Cloud Computing from SAP: The SAP Cloud Platform
- Blockchain with SAP: Business application scenarios for blockchains
- Blockchain with SAP: The First Steps to Having Your Own Blockchain
- Blockchain with SAP: Developing Applications with Hyperledger Fabric
- Blockchain with SAP: Developing Blockchain Applications with Hyperledger Fabric
- Blockchain with SAP: SAP HANA Integration
- Blockchain with SAP: MultiChain Applications
- Blockchain with SAP: Hybrid Network Architecture and Camelot Hypertrust Platform
- Blockchain with SAP: Summary and outlook
Would you like to find out more about the possibilities of MultiChain for your company? Our book “Blockchain with SAP” gives a detailed explanation of the advantages of MultiChain-based blockchain solutions. A detailed extract from the book is available online from the publisher.