How can other libraries be invoked from chaincode? - hyperledger-composer

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.

Related

OpenWhisk support of websockets and static websites

I'm choosing a serverless platform for my projects. I have explored AWS and found it excessively complicated: they provide an enormous bunch of settings but some basic scenarios are been too hard to implement.
The other platform looking promising for me is IBM Cloud with its OpenWhisk. And I'd like to check if the necessary capabilities are either implemented or in close plans for implementation.
Questions
Can I use websocket for my functions as a trigger for connect, message and disconnect? I found only a half year old discussion and nothing more. But this feature is demanded for real time applications.
Can I have static websites in both my custom domain and in subpath? I saw recipes where a docker container and lambda functions were employed. But writing my own implementation of Nginx looks nonsense. But this feature is also strongly demanded for single page applications (SPA) and there can be multiple such SPAs on one domain.
This blog with an IBM Cloud Functions overview has links and answers to your second question. There are tutorials on how to use custom domains with IBM Cloud Functions as backend for applications (see this tutorial with static page / SPA custom domain, and recipes for Express and Flask).
IBM Cloud Functions also has a package to post to Websockets. AFAIK there is functionality to listen to Websockets. My understanding is that serverless is incompatible with the "always on" nature of Websockets and the serverless runtime would need an API gateway or similar to manage the communication. If something is received, the action would be invoked.
Support for websockets for the ActionLoop proxy (used by Go,Swift,Python,PHP,Rust and Java) is here: https://github.com/sciabarracom/incubator-openwhisk-runtime-go/tree/websocket-support.
It can be used to build runtimes that support websocket but you need to deploy the runtime by yourself using Kubernetes. The support had ben postponed as an integration of OpenWhisk with Knative is a better path to include it in OpenWhisk.

Hyperledger composer for enterprise

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.

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.

Braintree Integration With Parse

I am currently trying to integrate Braintree in my cloud code because I would need Marketplaces payment functionalities in my IOS app.
I have been trying to use Braintree Node library by changing the require() paths, but there seems to be Node Modules (called with require(https) for instance) that cause problems.
Can these Node modules be integrated in Cloud Code?
I work at Braintree. If you have more questions about our client libraries, you can always talk to our support team.
This answer on parse.com suggests you copy http.js from your node installation into your cloud/ directory.
That said, I don't believe you'll be able to get the braintree-node client library working on Parse; it relies too much on the Node framework. Please let me know if you do get it working.

library/development platform on EC2/Rackspace/Eucalyptus/OpenStack

I am trying to build a cloud VM brokering service which can borrow computer power as VM's on-demand, from the private/public cloud computer infrastructure. I have following goals for my service.
Abstract out vendor specific API in to a library which will give flexibility to choose any of the vendors (eg. EC2, rackspace) VM's with out affecting my service built on top of the library.
Also I should have flexibility to borrow VM's from a pure private cloud infrastructure built using stacks like OpenStack/Eucalyptus. Due to huge upfront Capex we will be using public clouds but we plan to move to private cloud infrastructure. So from design perspective we want to hide those details transparent to brokering service.
My question is if there are any open-source/commercial libraries or cloud development platforms, which can give me this functionality over which I can just build my service without really bothering about vendor specific details.
I came across rightscale & scalr but I am not clear if they are tools or platform. I need a platform over which I can develop not just to tools to monitor and auto provision cloud deployments.
TIA.
For python there's boto and libcloud.
For Java there's jclouds and also a port of libcloud (scroll a bit further down the page).
These are all open source libraries.
Yes, there is! It's a ruby library called fog. It's the only library I have found which gives you a vendor agnostic interface to various cloud providers.
For an Openstack cloud (RackSpace and may be some other in future) you should consider using the following python libraries:
novaclient - client library for OpenStack Compute API
nova-adminclient - client for administering Openstack Nova
You will be able to write recipes to provision control and play with your VMs in an Openstack cloud.
Hope it helps. Let me know if you need any more help in this regard.

Resources