kandi X-RAY | fabric-sdk-node Summary
kandi X-RAY | fabric-sdk-node Summary
The Hyperledger Fabric Client SDK makes it possible to use APIs to interact with a Hyperledger Fabric blockchain. This readme is directed towards a current or future contributor to this project, and gives an overview of setting up the project locally and running tests. For more information on the SDK, including features and an API reference, please visit the SDK documentation.
Top functions reviewed by kandi - BETA
- Decode a config value .
- Decode a private data map
- Decode an envelope data .
- Decode a KRS string into an object .
- Decode policy policy
- Decode a single subject .
- Decode the query query info .
- Decode the enderer transaction data .
- Returns true if signature parameters are more than the result
- Decode a read data set
fabric-sdk-node Key Features
fabric-sdk-node Examples and Code Snippets
docker run -it -v $PWD:/nodejsAction openwhisk/action-nodejs-v10 "npm install"
zip -r action.zip *
ibmcloud wsk action create my-action --kind nodejs:10 action.zip
npm i --save fabric-network
Trending Discussions on fabric-sdk-node
I'm writing a fabric client application using nodejs and the latest fabric-network library. I have setup multiple orderer nodes running in VMs and want to prioritize which orderer node to be used when submitting transactions.
I wrote my own connection profile including the above orderer nodes and let the application use it to create gateway object. Then, I'm calling transaction#submit method to execute transactions. I want to use the nearest orderer node from the application but I don't know if it's possible.
I read through fabric-skd-node source code and found that commitment procedure is done at Commit.js#send method and it pick the first healthy orderer node from the orderer list retrieved using Channel.js#getTargetCommitters method. So, my rough guess is that the first orderer node listed in connection profile is used if it's connectable.
Please correct me if I'm wrong, I'd be very grateful....
ANSWERAnswered 2022-Feb-04 at 15:46
It looks like you are correct in the case that you are not using service discovery, and you client is only using nodes defined in your connection profile.
If you are using service discovery to dynamically discover network nodes then the list of orderers is randomised on each invocation to help distribute load more evenly across orderers and better handle orderer outages.
Remember that orderers will replicate transactions they receive to other orderers to maintain consistency and avoid single points of failure, so you are not avoiding transactions being sent to more distant ordering nodes.
I am trying to build a decentralized app that able to do show the block header like data hash, the previous hash of the block when a user submits a new transaction. However, It seems like the new version of Fabric Node SDK 2.2 removes the function queryblock.
I refer on the documentation at https://hyperledger.github.io/fabric-sdk-node/release-2.2/module-fabric-network.html and currently still looking for some workaround to show the block info of the user's transaction.
The ideal output that I wish to achieved is almost similar to what Hyperledger Explorer provide.The reference can be check at:
which show the information such as Number of Blocks, Data Hash, Previous Hash and other Block Information regarding the hash.Some information that I able to gather
There are some information like BlockEvent that have the name
blockDatain the interface
BlockEvent. However, I can't seem to find it when
npm install i fabric-network.
Since the user can query and check their hash with the ledger, a key or hash need to be returned to the user upon transaction success. Is there any API function for this? So far, I able to found there are
getTransactionId()in the class
Transaction. But is this one that I need to use?
All of the reference since to deal with the old version of node SDK which is version 1.4.
- Hyperledger Fabric : How to Query blocks using fabric NodeSDK
- HyperLedger Fabric Get Block Info - using node.js
- how to display current hash,previous hash using node js on view pages for hyperledger fabric
- How to get history of asset with block hash in hyperledger fabric using node sdk
ANSWERAnswered 2021-Mar-23 at 10:30
You can query block number by call function
qscc contract. Example:
I am trying to sign transaction proposals with offline key. I have generated signed certificate by
Org CA and now I am trying to create
fabric-common nodejs SDK version 2.2.5.
ANSWERAnswered 2021-Mar-17 at 11:45
So the problem was that I was using node
v12.6.0 which is required by
fabric-common module. When I downgraded node version to
v11.6.0 and installed dependencies with flag
--ignore-engines everything worked as expected.
I'm trying to connect to an HSM using fabric-network V1.4.17 looking at the HSMWalletMixin constructor there are no options to tell the class the library label and pin.
Instead all these variables can be found in the X509WalletMixin.
Here's the code in the class:...
ANSWERAnswered 2021-Feb-19 at 22:18
Looking at the source code the implementation is correct https://github.com/hyperledger/fabric-sdk-node/blob/4ca22aa1a70f464c3a5b9c259542aa7fee651061/fabric-network/lib/impl/wallet/hsmwalletmixin.js#L40
What is not correct are the type definitions which is the code snippet you have posted.
It's only going to be an issue if you are using typescript in which case you will just have to not use the HSMWalletMixin type to ensure typescript doesn't try to do any validation.
I use hyperledger fabric V1.4.10 I created a deployer app that installs and upgrades my chaincode using the node SDK API and everything works great but I am storing all my project compressed in a zip file as an artifact and I would like to have a smaller artifact to store, off course I'm adding the node modules, the js and the ts files, as I'm not completely sure if they are needed or not during deployment.
I would like to be able to do the same that is done using "peer chaincode package" from my deployer app to be able to package my code in an efficient way.
I have seen in the SDK a BasePackager class that seems to be able to package the code, but I can´t find any examples of how to use it.
Also looking inside the js code I found that the install method can receive a ChaincodeInstallRequest that can be a ChaincodePackageInstallRequest or a ChaincodePathInstallRequest.
Here's the code inside index.d.ts:...
ANSWERAnswered 2021-Feb-02 at 02:24
The Node SDK does not (currently) include admin capabilities such as lifecycle deployment of chaincode. If you can use the peer CLI commands then that is probably a good option since they are well supported and maintained. Alternatively, there is at least one admin package aiming to provide this capability to Node applications: https://www.npmjs.com/package/khala-fabric-admin There is a lack of documentation.
The fabric-sdk-java API has some Lifecycle-related functions on HFClient and Channel:
However, I'm not certain they are really up-to-date with the current Lifecycle deployment implementation so I'm not sure I would recommend relying on them
The peer chaincode lifecycle CLI commands are better maintained and supported so, if you can make use of them, I would recommend that instead: https://hyperledger-fabric.readthedocs.io/en/release-2.2/commands/peerlifecycle.html
From what I'm reading, it is only possible to pass string values from the Node SDK to the chaincode via submitTransaction.
However, from the chaincode point of view, there is no issue with creating an asset containing, say, booleans and integers and store them.
Hence my question: is storing non-string attributes considered a bad practice, and if not, what is the best way to implement it? Of course I can send strings that the smart contract will then convert back to bool/ints, but that sounds quite ugly. I also guess that instead of sending
...args I can send a JSON, but again, quite ugly.
ANSWERAnswered 2020-Jun-02 at 17:38
Okay, this is from JAVA HLF implementation standpoint. Assuming Node JS and Java have the same capabilities, the 'putState' method takes in either 'byte' or 'String' data types, and putState is the only method as far as I know to put data to ledger. So, you cannot put anything other than String/ byte in my view. So, although it is ugly, I think putting String or bytes to ledger is the only way to put and get data (at least as of HLF 1.4).
All data written to ledger would actually get stored onto 'CouchDB' behind the scenes, so if you write JSON strings to ledger, you can later write 'CouchDB query' and get the data from ledger too (just like how you use SQL to get data from traditional RDBMS).
i am building a blockchain on hyperledger fabric (node.js SDK).
i call the api BlockchainInfo and get a json format response, which includes currentBlockHash
the offical document shows that the response data type of currentBlockHash is Array< byte >
such as the following data.
i would like to convert this buffer to string but have no idea what to do.
thanks for your reading the question....
ANSWERAnswered 2020-May-07 at 16:17
I think the JSDoc is misleading in this case. I think the
currentBlockHash will actually be a Node.js Buffer (or possibly a protobuf implementation that emulates the behaviour of a Buffer). You can convert a Buffer into a string by calling
I have observed some cases where calling toString() on a protobuf Buffer implementation gives a debug string rather than a string representation of the content of the buffer so I tend to specify an encoding argument just to be safe.
In the case of a hash it may be more convenient to see it as a hex string rather than utf8 (which would be the default) anyway, so I would try
See here for more information on Buffers: https://nodejs.org/docs/latest-v10.x/api/buffer.html
Can anyone help me to find FabToken source code of Hyperledger Fabric? And an example of Smart contract that use it?
I've already check a lot of links, for example:
but they don't works.
FINAL UPDATE (for other users)
this is the code of FabToken...
ANSWERAnswered 2020-Feb-07 at 10:21
Sadly, even though Fabtoken was included in the v2.0 alpha version, it was decided to be git-reverted and therefore Fabric v2.0 will not come with the Fabtoken feature.
I am trying to modify
fabric-sdk-node project to use it with RSA certs and keys.
And for now I have no idea on how to produce a SKI (X509v3 Subject Key Identifier) with a RSA public key.
That project is using
jsrsasign package on the crypto things.
I have found in the
jsrsasign issue page on Github.com which can produce SKI with ECDSA, but still no clue in the RSA ones.
Any advice will be welcomed!
ANSWERAnswered 2020-Mar-02 at 07:58
I have almost test every method in package
jsrsasign, but still not found anything useful.
So I look outside the box and think, the X509V3 Subject Key Identifier(SKI) was produced by the default
sha1 hash algo. However, what we have done in the hyperledger/fabric, defined that the hash algo to be
sha256. So what if the
jsrsasign has made that hash algo hardcoded with
sha1? (This is a guess, please correct me if I am wrong.)
With that thought, I have tried on another package
node-forge, which just solved my problem.
Here is the demo:
I am trying to add a new Org to an existing Hyperledger fabric network.
The initial network is created by the byfn.sh script that stands up an Orderer and Org1 & Org2.
I have followed this example on Medium.com to create the update protobuf file. Everything that requires configtxgen, cryptogen and configtxlator is done as per this example. However, when it comes to executing the command
peer channel signconfigtx -f org3_update_in_envelope.pb, I would like to do that using the Fabric Node SDK.
A point to note here is that if I execute the
peer channel ... commands from the cli container command line, the channel update goes through, so I know that the file org3_update_in_envelope.pb is not corrupted.
ANSWERAnswered 2020-Jan-20 at 10:10
The default policy for updating a channel requires a majority, which in your case means you will need signatures from both Org1 admin and Org2 admin and then either Org1 or Org2 can send the actual config update to the orderer.
This means that you need to run
No vulnerabilities reported
Node.js, version 10 is supported from 10.15.3 and higher
Node.js, version 12 is supported from 12.13.1 and higher
npm tool version 6 or higher
docker (only required for running integration tests, see below)
Reuse Trending Solutions
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page