Preface – This post is part of the Blockchain on SAP Cloud Platform series.
Table of Contents
Everybody is well aware with bitcoin. Bitcoin is the first cryptocurrency based on blockchain. Apart from cryptocurrency, this blockchain can be used as a platform for other data based sectors. Keeping this in mind, a private blockchain network was introduced by Multichain for Enterprises and finance sectors. In this article, we will explore basics of Multichain and how SAP has integrated it in to its SAP Cloud Platform. Before we start with Multichain, we recommend you to read What is Blockchain?
What is Multichain
According to the official Multichain whitepaper, Multichain is a platform which uses integrated management of user permissions to create private blockchains. Even, Multichain is derived from bitcoin. Multichain supports Windows, Linux and Mac servers. Multichain based blockchain network was developed to overcome shortcomings of Bitcoin such as generic mining, privacy and openness.
Pros and Cons of Private Blockchains
Multichain has both pros and cons. Private blockchains, such as Multichain, are the one that are controlled by single or multiple organizations that determines who can read it, submit transactions to it, and participate in the consensus or mining process. Thus, it brings both advantages and disadvantages with itself.
One major disadvantage is that it does not support smart contracts [Although upcoming versions might have Smart contracts too]. According to official SAP website, “Since they are 100% centralized, private blockchains are useful as sandbox environments, but not for actual production.”
Mining in Multichain
Unlike Bitcoin, from which it is derived, Multichain does not depend only upon the concept of Proof of Work that can be owned by a single institute in some situation. It utilizes a round-robin schedule, in which the permitted/authorized miners have to create blocks in rotation to generate a valid blockchain. This scheme is implemented in Multichain using a parameter called Mining diversity.
A mining diversity is a concept in which its values are defined value between 0(No restriction) and 1(Every permitted miner must be included into rotation). In actual scenario, mining diversity is kept 0.75 which means if some miners are inactive, still the mining and rotation is possible. Now, based upon mining diversity value fixed by the blockchain administrator or moderator, following are the steps for validations that are required to add a block in the blockchain:
- All the changes that a transaction defines should be applied successfully and in order (It means an incomplete and unordered transaction cannot be added into a block)
- Count the miners that are permitted to mine (suppose 10)
- Multiply the miner count to mining diversity (suppose 10 * .75 = 7.5), round it up to get spacing (here 8)
- If the miner of this block has already mined the previous spacing (spacing – 1, here 7) then the block is invalid
Miners in Multichain neither charge transaction fees nor block rewards. Hence, transaction is free between two parties. However, a miner or an administrator can charge a fixed service fee from the blockchain network participants. SAP too applies this type of fees methodology and charges a fixed amount for a Block per hour.
Configuration of Blockchain in Multichain
In a configuration file, Multichain allows a user to set all the blockchain’s parameter that are mentioned below:
- Type of chain protocol (Private Blockchain for Enterprises or Bitcoin like Public Blockchain)
- Target time for each block (time taken to add block, e.g. 1 min)
- Active permission types (e.g. Anyone can connect, only some can send/receive)
- Mining diversity (as discussed above, it will be a value and it is mainly 0.75)
- Level of consensus (authorization) required for creating/removing administrators, moderators and minors
- Mining reward or fees (as discussed above, it can be zero too)
- IP ports for peer-to-peer connection and the JSON-RPC API (will discuss later)
- Permitted transaction type (e.g. pay-to-address, etc.)
- Maximum block size (e.g. 1 MB)
- Maximum metadata per transaction i.e. size of file that can be sent to the blockchain as transaction (termed as OP_RETURN; e.g. 4096 bytes)
As discussed in the earlier blog, these configurations are maintained in the first node or Genesis block. To add a new node, Multichain requires to be run from another computer using a node address (e.g. firstname.lastname@example.org:8571) with three parameters:
- The destination blockchain name (here chain1)
- Its IP port number (here 184.108.40.206)
- The IP address of an existing node (here 8571)
Implementation of MultiChain using SAP Cloud Platform
This is a generic architecture where it is shown how a MultiChain network is setup and how SAP Cloud Platform communicates with a MultiChain Node. If you want to explore more regarding Multichain Architecture, then refer here. We will be publishing individual courses of Multichain soon.
Setup of MultiChain on Cloud Platform
To Create a MultiChain on SAP Cloud Platform, initially we need to setup our Global Account on SAP Cloud Platform and create a MultiChain enabled sub-account. Then only we can proceed with development.
Following the following steps to enable MultiChain on your Cloud Platform:
Step 01: Go to your trial cloud platform and select region as Europe (Frankfurt) – Canary.
Step 02: Create a sub account under your cloud platform space [Give your desired Display name and Subdomain name].
Step 03: Click Entitlements button from the left menu bar as shown in image below.
Step 04: Inside Entitlements menu, you will see Edit button, click it to change the mode to editable and scroll down to Multichain as shown in the image below:
Step 05: Click your sub account (the one you created above) to open it. Click Spaces and create a new space giving all authorization to that space as shown in the image below:
Step 06: Click on the space that you have just created above and select Service Marketplace. Scroll down to MultiChain and click to open it as shown in the image below:
Once the initial setup of MultiChain is done, you can create your own nodes and instances. Follow Hands on Exercise created by a SAP developer to create your own SAP MultiChain service.