Integrate your Blockchain with anything using Hyperledger Composer and NodeRed

Firstly, some quick background. What is Hyperledger Composer? It’s a framework for rapidly building Blockchain business networks on top of a Blockchain platform, such as Hyperledger Fabric. It’s pretty cool. You can find some more information here:

Blockchain is a technology for building networks that connect organizations together. Once started, a Blockchain network allows participants to transfer assets between each other by submitting transactions, and those transactions are recorded in an immutable ledger.

So once you have your Blockchain how do you easily integrate it with other things. Well now you can use Node-Red. Node-Red is a programming tool for wiring together hardware devices, APIs and online services.

If you don’t have Node-Red already you can download it from Once installed and running you can add new nodes by clicking on the menu icon-> manage palette and click install then search for node-red-contrib-composer.

You should now have three new nodes in your palette

You can now use the nodes within your flow. You just need to set the connection profile name, business network name, user ID and user secret. These will allow the nodes to communicate with the Blockchain. Now you can create, update and retrieve assets or participants, submit transactions, and listen on events.

In this example I have deployed the basic-sample-network to a Blockchain. I have created these flows in Node-Red as an example of how to use the nodes.

The output nodes enable you to create and update assets and participants or submit transactions. The Input node listens to events from a transaction. The mid-flow node retrieves assets or participants.

In the first flow this is creating a participant. I have used an inject node for simplicity but this could be any node. You could use the twitter nodes to listen for tweets and then put the contents of the tweet on the Blockchain.

To be able to inject some JSON into the flow the inject node looks like this.

The JSON to create a participant looks like this

{   "$class": "org.acme.sample.SampleParticipant",   "participantId": "CarolineID",   "firstName": "Caroline",   "lastName": "Church" }

This is exactly the same JSON you would write if you were creating the participant through composer-playground. When you deploy the flow you can then click on the button next to the inject node and this will inject the JSON and then the Hyperledger-Composer node will then create that participant. You can create or update assets and submit transactions in the same way.

The Hyperledger Composer In node is wired up to a debug node so when an event is emitted the node will get notified and the information in the event is then passed to the flow. The debug just outputs the contents of the message. This though could be changed to use other nodes. For example tweet whenever a transaction happens on the business network.

The Hyperledger Composer Mid node retrieves assets and participants from the Blockchain. The JSON to retrieve the resource looks like this

{"$class" : "org.acme.sample.SampleAsset", "id" : "1234"}

The data that is returned will be in the msg.payload.

So now you can integrate anything with Blockchain and Node-Red go get integrating!!!!