Integrate Biz Network using Blockchain

Applications Technology
Jun 10 · 4 min read

Blockchain technologies for business

Open-governed community for enterprise blockchain hosted by the Linux Foundation

Follows the same core practices that were behind the success of Linux

Over 200 organizations from many industries and major tech players

Image for post
Image for post

Fabric — open-source platform for distributed ledger solutions that is intended as a foundation for developing blockchain solutions

Provides a permissioned blockchain model with membership services

No cryptocurrency required!

Offers a modular architecture allowing components, such as consensus and membership services, to be plug-and-play

Programmable — Leverages containers to host smart contracts for automating business processes

Focuses on a scalable implementation with confidentiality/privacy provisions

Enables pluggable data store, consensus protocols, and multiple providers of membership services

  • Permissioned

-Identity management through Membership Services Providers

  • Programmable

-System chaincode defines operations rules and manages policies, deploys application chaincode.

-Application chaincode for running smart contracts

  • Scalable

-Separates smart contract execution (endorsement) from consensus (ordering)

  • Enables partitioning of chaincodes between endorsers
Image for post
Image for post

We understand the characteristics of blockchain. Now let's see how key components are stitched together.

We can think of a three layer system:

1.Application layer - This is a client application where transactions are initiated. Users need to get registered to access the blockchain network. Registered users can initiate the transactions and query their ledger. They can also register for certain events to continuously monitor the blockchain network.

2.Business logic layer – This is where the smart contract/chaincode comes into picture. It becomes an interface between the Application layer and the Infrastructure layer. It gets a request from the client and based on the access it executes the business logic, retrieves the records, and sends it back to the Application layer.

3.Infrastructure layer - This is the layer where we have the ledger and world state. World state is a database where the latest state of a transaction is stored. I will talk about this in detail later. Just keep in mind that chaincode interacts with world state.

These features make the system robust and trusty, and ensure transparency among all participants.

Image for post
Image for post

To develop a Chaincode in an application, the following aspects should be available.

1.Chaincode Interface — It is implemented by the Chaincode to call the API. This interface has two methods, namely Init() and Invoke(), which accepts “stub shim.ChaincodeStubInterface” as a parameter to call the APIs and returns a “pb.Response” where pb is “Protocol buffer,” a type that is language and platform neutral.

-When the Init, Invoke, or Query function of a Chaincode is called, the fabric passes the stub *shim.ChaincodeStub parameter. This stub can be used to call APIs to access the ledger services and transaction context or to invoke other Chaincodes.

2.Chaincode API — Shim API is used as the Chaincode API that acts as an interface between the golang code and peer.

3.Chaincode Response — The Chaincode response will be in .proto format (protocol buffer format). It’s Google’s platform and a language neutral mechanism for serializing structured data in a simpler, smaller, and faster way.

For more information:

Protocol Buffer —

Shim API —

Image for post
Image for post

package main

import (

// Import libraries required


type TestChaincode struct { // Declare chaincode


func (t *TestChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {

return shim.Success(nil)


func (t *TestChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {

return shim.Success(pbmessage)


func main() {

err := shim.Start(new(TestChaincode))


Testing a Chaincode Using a Mock Shim

  • Done using the mock version of the shim.ChaincodeStubInterface
  • Use this stub to simulate some functionality of the Chaincode before deploying it to the OBP
  • Can be used as a library to build the unit tests for the Chaincode

// Invoke the chaincode, also starts and ends a transaction.

func (stub *MockStub) MockInvoke(uuid string, args [][]byte) pb.Response


stub.args = args


res :=


return res




Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store