Hyperledger composer for enterprise - hyperledger-composer

I saw that Hyperledger composer is really easy to work with, also we can deploy the composer code on hyperledger fabric. But I found that they create only one channel, and we will have the flexibility to talk to the specific peers like what we can do in GoLang\fabric, can we call external web services from composer java script code as we can do in Golang on fabric?
I'm wondering, can we use hyperledger composer for enterprise blockchain applications? or just we use it to create blockchain POCs.
Regards.
Bassel Kh

Hyperledger Composer is intended to be used for enterprise blockchain applications, although Composer Playground is not intended for Production use.
Composer connects with Fabric using Business Network Cards, and these contain credentials and a Connection Profile. The connection profile contains definitions of the 'services' on the Fabric, and so it is possible to define specific Peers within the card.
Regarding channels - it is again the Connection Profile that determines the Channel used, and at the moment only one channel is supported per Card. Multiple cards can be used but disconnect/switch/re-connect might not be practical or desirable in some cases.
There is a way to connect to a different Business Network on a different Channel covered in this tutorial, but again it might not be suitable for all cases.
There is an outstanding issue on GitHub for using Composer for multi-channel, so you can leave a comment or +1 on it - particularly if you have a good use case for multi-channel.
Many people are thinking of and using channels as a security feature, but Composer ACLs might solve that issue in some cases. Similarly the upcoming sidedb feature in Fabric might offer security instead of separate channels.

yes, you can call external web services and get the results back into your smart contract code or client see -> https://hyperledger.github.io/composer/latest/integrating/call-out
yes Hyperledger Composer is intended for Enterprise blockchain applications. Your applications will use Composer client to write application data to the ledger, and its production runtime is where the 'chaincode' smart contract/business network is deployed/installed on the peers (just like Go chaincode is similarly deployed). One such provider using Composer is here -> https://ibm-blockchain.github.io/platform-deployment/
Finally also see here -> https://github.com/hyperledger/composer-knowledge-wiki/blob/latest/knowledge.md#production for more info.

Related

How to generate individual ledgers for individual participants

I'm new to Blockchain. I heard that blockchain provides individual ledgers for individual participants. I want to know how it will work with Hyperledger Composer Blockchain application.
Hyperledger Composer is built on Hyperledger Fabric - which is a permissioned, distributed, shared ledger.
If you are new to Composer, I would suggest working through the documentation, in particular the tutorials.
More information on Fabric is available in the Fabric documentation.

I have written code in GoLang then how to get chain code using Hyper-ledger Fabric Composer?

I have set up composer-rest-server successfully using this link on IBM cloud. I have written custom logic code in GoLang for getting chain code. I don't know how will proceed for next setup for getting chain code. Could you help me by showing me which way I have to proceed?
Chaincode for Hyperledger Composer is written in Javascript not GoLang. (Though Hyperledger Fabric supports both GoLang and Javascript with V1.1).
If you wish to proceed with Composer and Javascript, you could start with the Developer Tutorial, then follow this document for information on Developing Applications.
Update following Comment
There is a Fabric Tutorial "First Application" that uses go for the chaincode.
With regard to IBM cloud, it is possible to use Composer Business Networks, or write direct chaincode for the Fabric with IBM Cloud Starter Plan, and there are examples to "auto" deploy.

Overhead to using composer-rest-server over JavaScript / Node SDK?

We are trying to figure out best design practice while using hyper-ledger composer. We have following questions :
1) if We are using composer-rest-server, then will have to manage two server side components.
i) running composer-rest-server ii) running application which will send request to composer-rest-server to communicate to network.
Isn't it overhead? what additional advantages we are getting by using composer-rest-server? in fact, probably client will have to authenticate two times i guess.
2) If we are using JavaScript SDK, then will have to manage only one server side application, kindly correct me in case of misunderstanding.
3) When i generated angularjs application using yo generator, its also asking me information of composer-rest-server, but I am not planning to use composer-rest-server and want to use 'composer-client' and 'composer-admin' only.
Yes, there will be some overhead of running the composer-rest-server in its own process, however it will allow you to secure and scale your rest servers independent of your application. Depending on your scenario that may be an overhead worth paying.
Another option would be to generate a LoopBack application (using the lb tools) that uses the loopback-connector-composer LoopBack connector directly. This may give you access to the underlying Express server and would allow you to merge your application and the REST server.
You are correct, however you would have to build the REST API for your business network yourself, and manage authentication and certificates.
The generated Angular application uses the REST API exposed by the composer-rest-server to interact with HLF.
Here is a DRAFT topology diagram that I am working on for contribution to the documentation.

How can other libraries be invoked from chaincode?

In https://hyperledger.github.io/composer/reference/MeetTheModules.html it says:
composer-client and composer-admin are the two modules that provide APIs for applications. node.js applications should only use APIs that come from these modules. If there are other APIs that are need please contact us.
If I had chaincode which needed to call out to an AWS service using the AWS Node SDK for instance, is this one of the scenarios where we should contact the dev team? I'm new to node.js btw, so apologies if this is an obvious question.
chaincode (or transaction processor functions in Composer terms) are executed in a JavaScript virtual machine written in Go, not Node.js. It is currently not possible to import Node.js modules from a transaction processor function or call out to an external service.
We are very interested in adding Node.js chaincode support to Fabric, this is work we are planning on starting.

What is the recommended way to invoke and query data/transactions that were modeled using Fabric Composer?

I am building an PoC using Fabric v0.6 and composer-ui. The question I have is regarding how to interact with the Fabric peers once I have deployed my .bna file in the Fabric network. In the past I have made invoke and query calls to my chaincode using gRPC and passing the function name and arguments through the call. In the case of chaincode deployed through composer, there is a whole abstraction happening so I am not sure if the name of my transactions created in composer translate exactly to names I can call via my gRPC calls on the client side (my node application). I also don't know if the arguments that I pass to the chaincode are the same or if any special argument is expected.
So I guess my question is, from the client side, how do I make calls to transactions in my chaincode that have been creating using Composer? Are there client examples out there for Fabric v0.6? Thanks!
The first example that comes to mind is the sample-applications repository at https://github.com/fabric-composer/sample-applications
if you look in the sample-applications/packages/getting-started there is an example of a client application. The landRegistry.js file in the lib directory contains the bulk of the code used to interact with the business network.
There is also an application generator which is described in more detail at
https://fabric-composer.github.io/applications/genapp.html
You can also find reference documentation for both client side and businessnetwork implementations at
https://fabric-composer.github.io/jsdoc/
You should also consider using the REST API that Composer can generate for your business network.
npm install -g composer-rest-server
composer-rest-server
Then fill in the details required to connect to your business network and the composer-rest-server will expose a Swagger defined REST API that you can exercise using Swagger UI. The REST API is expressed in terms of the assets, participants and transactions that are modeled in your business network.
More docs here:
https://fabric-composer.github.io/integrating/getting-started-rest-api.html
The advantage of using the REST API is that it keeps the coupling between the client application and the blockchain loose; the client doesn't need any Composer libraries and doesn't even need to know that the data source is a blockchain.

Resources