Hyperledger fabric gRPC interaction - hyperledger-fabric

I've been messing around with gRPC and I was looking into building my own simple and comprehensive hyperledger fabric SDK in rust.
I've looked everywhere for any gRPC spec of hyperledger fabric to see how we can reproduce the functionality of interacting with the peers, stuff like managing channels and performing invokes and queries.
(reproduce this behavior: https://hyperledger-fabric.readthedocs.io/en/release-1.4/commands/peerchannel.html).
Online, everyone says that the functionality is exposed over gRPC, but that they recommend using an existing SDK.
I've inspected the nodeJS SDK and looked for their .proto files, but there are barely any services (https://github.com/hyperledger/fabric-sdk-node/tree/release-1.4/fabric-client/lib/protos)
Is there any way to get their gRPC spec? is there a generic way to do this for gRPC servers? Why is it so hidden?
Thanks!

I believe the protos are recently relocated to https://github.com/hyperledger/fabric-protos for the master branch, which is not yet released.
For an as current 1.4 based project, look at the protos/ directory in the main fabric repository. https://github.com/hyperledger/fabric/tree/release-1.4/protos

Related

Are all administration functions for the channel joining, chaincode installing/upgrading removed from fabric-network / fabric-common?

I'm preparing that my client server using the old v1.4 fabric-client SDK to the new v2.1 fabric-network and fabric-common SDK. In my old server, I built many administration functions such as;
creating channels
joining peers to channels
updating channel configs such as batchSize
instantiating/upgrading chaincodes
However, I cannot find any APIs from fabric-network or fabric-common to do these administration things. For example, there is no installChaincode function from Client class in fabric-common.
How can I implement these administration operations using the v2.1 fabric-network and fabric-common SDK? Or, should I think another way such as using peer CLI (which I never want to do) rather than implementing the administration server to control the Hyperledger Fabric network?
If SDKs of other languages such as Golang or Java have such APIs, then let me know please. I'm okay to develop the administration server using other languages than JavaScript, if possible.
I've checked about it and I got an answer that all admin APIs had been removed from all SDK including node, Java, etc. This is a confirmed decision, so, at this point, finding other options such as using CLI is a way to do some admin stuff.

Can I query Hyperledger Fabric directly from a WebApp?

I'm really new to Hyperledger and blockchain. From what I understand, the whole meaning of the blockchain is to build decentralized applications, not depending on a single server.
So my question is: Is there a way to query and work with a Fabric node directly from a web browser? I believe Ethereum solves this problem with web3.js.
Thank you very much for your help.
Short Answer: No.
Web3.js communicates with Ethereum over JSON RPC and is supported by browsers.
Hyperledger Fabric, on the other hand, uses Protobuf over grpc. Currently, there is no such implementation like web3.js that can communicate directly using a browser with Hyperledger Fabric.
However Hyperledger Burrow, that provides a permissioned version of Ethereum and supports Solidity Smart Contracts does not yet support web3.js, but it is something they have in their roadmap and shall support soon.
Check this for more updates: https://wiki.hyperledger.org/projects/burrow/roadmap_2018_q1
To mimic a network for testing you can use composer-playground.mybluemix.net and to test your assets/transactions once deployed on Fabric, you can use Composer's REST API to make calls to localhost.

Hyperledger -- how to set up REST API for invoking Chaincode

I'm playing around with Hyperledger and am trying to figure to figure how to set up the server with REST api for chaincode defined here https://openblockchain.readthedocs.io/en/latest/API/CoreAPI/#rest-api
Unfortunately many of the links are dead, so I'm not sure how to set it up. I understand the query language, I just don't knopw how to begin the web server.
Does anyone have any ideas?
Hyperledger Fabric v1.0 and later does not provide a native REST API for interacting with peer and/or orderer nodes. If you have not done so, I'd advise taking a look at http://hyperledger-fabric.readthedocs.io/en/release-1.1/ to better understand the current Fabric architecture.
There is a project to provide a REST API server in front of Fabric nodes. It was not updated to support Fabric v1.1 (at least not yet) but does support Fabric v1.0 and should provide at least an example of how to add a REST API in front.
I'd also advice taking a look at the samples which are documented here as well. The fabcar sample provides a nice, simple example of how to connect a Node.js application to Fabric.

Hyperledger Composer vs Hyperledger Nodejs Api

I am new to hyperledger and bit confused about hyperledger composer & nodejs api.
I saw using composer we can create assets, transactions, participants and chaincode and in last we have to archive it this all into .bna file and finally we deploy this chaincode into network using admin card
But at other end using NodeJs API we can also write chaincode by overiding init & invoke methods.
How can we relate these all.
The best way to think about this is the following:
1) Hyperledger Fabric v1.1 supports writing chaincode in two languages: Golang and JavaScript via Node.js
If you want to do all of the heavy lifting yourself, you can write straight chaincode.
2) Hyperledger Composer provides a higher-level model-driven language for developing smart contracts. It currently only allows deployment of these artifacts to Hyperledger Fabric. It also happens to support writing functions in JavaScript as well.
So if you want to start from a higher-level model-driven approach, Hyperledger Composer is the way to go. If you want to write all of the plumbing yourself or use very low-level chaincode features, then using chaincode itself is the way to go.
Moving forward, we are looking at a better way to move between the two and not force a decision / direction up front.
There is another option, we develop a framework called Convector to be in the middle of Composer (high abstraction, low control) and raw code (low abstraction, high control, therefore high risk). We open sourced it a few days ago. At WorldSibu we don't like loosing so much control over our code like with Composer but as Gari Singh was saying, doing all the heavy lifting for each project is crazy. It is like a Mongoose for Hyperledger Fabric. It may help to check it out.
It is also worth noting that, according to IBM, Composer is no longer recommended as a production solution, but only for prototyping. In HLF 1.3, chaincode can now be written in Go, Javascript and Java.

What does Hyperledger composer do .Does that create chaincode for fabric or something else?

I have been working on hyperledger fabric for some time. But I don’t understand where hyperledger composer comes in place . I do understand that it helps in visualizing the logic and transaction. But what I don’t get is how do you integrate it with fabric network? what does it create? Is it chaincode if not then what?
The Compose runtime is chain code that executes the business network archive artefacts created by the end-user.
Perhaps this will help?
https://blog.selman.org/2017/07/08/getting-started-with-blockchain-development/
The tech answer is that Hyperledger Composer is an abstraction layer over Hyperledger Fabric.
The practical answer is that it is awesome. Think how Angular and hundreds of other frameworks make web programming easier.
It is a framework where you can write your blockchain in Javascript and specify your data objects in an easy to understand text file. Throw in some querying, ACL stuff and pathways to use some nice opensource tools that let you do things like generate a Web API automatically and play around in a web environment without installing anything.
We are using it for the Integra Ledger Legal blockchain. (www.integraledger.com). I just spent the day working in it.

Resources