fabric-sdk-node | Hyperledger Fabric SDK for Node https | Blockchain library

 by   hyperledger JavaScript Version: v2.2.17 License: Apache-2.0

kandi X-RAY | fabric-sdk-node Summary

kandi X-RAY | fabric-sdk-node Summary

fabric-sdk-node is a JavaScript library typically used in Blockchain applications. fabric-sdk-node has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can install using 'npm i zhigui-fabric-client' or download it from GitHub, npm.

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.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              fabric-sdk-node has a medium active ecosystem.
              It has 768 star(s) with 522 fork(s). There are 62 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 5 open issues and 34 have been closed. On average issues are closed in 76 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of fabric-sdk-node is v2.2.17

            kandi-Quality Quality

              fabric-sdk-node has 0 bugs and 0 code smells.

            kandi-Security Security

              fabric-sdk-node has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              fabric-sdk-node code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              fabric-sdk-node is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              fabric-sdk-node releases are available to install and integrate.
              Deployable package is available in npm.
              Installation instructions are available. Examples and code snippets are not available.
              fabric-sdk-node saves you 651 person hours of effort in developing the same functionality from scratch.
              It has 1511 lines of code, 83 functions and 320 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed fabric-sdk-node and discovered the below as its top functions. This is intended to give you an instant insight into fabric-sdk-node implemented functionality, and help decide if they suit your requirements.
            • 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
            Get all kandi verified functions for this library.

            fabric-sdk-node Key Features

            No Key Features are available at this moment for fabric-sdk-node.

            fabric-sdk-node Examples and Code Snippets

            How to use Hyperledger Fabric node SDK packages in an IBM Cloud Functions action?
            JavaScriptdot img1Lines of Code : 15dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            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
            
            Error while testing fabric sample fabcar example
            JavaScriptdot img2Lines of Code : 2dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            npm i --save fabric-network
            

            Community Discussions

            QUESTION

            is it possible to prioritize orderer when submitting transactions through fabric-sdk-node?
            Asked 2022-Feb-04 at 15:46

            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.

            ...

            ANSWER

            Answered 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.

            https://github.com/hyperledger/fabric-sdk-node/blob/3da1d0beeb5274b021d6bd4a6d8ea69d5642d409/fabric-common/lib/DiscoveryHandler.js#L106-L109

            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.

            Source https://stackoverflow.com/questions/70949854

            QUESTION

            Hyperledger Fabric Version 2: How to query Block Header such as data hash, previous hash by using Fabric Node SDK 2.2
            Asked 2021-Mar-23 at 10:30

            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
            1. There are some information like BlockEvent that have the name blockData in the interface BlockEvent. However, I can't seem to find it when npm install i fabric-network.

            2. 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?

            StackOverflow reference that I had gone over:

            All of the reference since to deal with the old version of node SDK which is version 1.4.

            ...

            ANSWER

            Answered 2021-Mar-23 at 10:30

            You can query block number by call function GetBlockByNumber of qscc contract. Example:

            Source https://stackoverflow.com/questions/66560539

            QUESTION

            Fabric-common: TypeError: cryptoSuite.createKeyFromRaw is not a function
            Asked 2021-Mar-17 at 11:45

            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 User with fabric-common nodejs SDK version 2.2.5.

            ...

            ANSWER

            Answered 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.

            Source https://stackoverflow.com/questions/66655105

            QUESTION

            The constructor for HSMWalletMixin in HLF 1.4 doesn't have the correct variables
            Asked 2021-Feb-19 at 22:18

            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:

            ...

            ANSWER

            Answered 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.

            Source https://stackoverflow.com/questions/66283689

            QUESTION

            Is it possible to package the Hyperledger Fabric chaincode using the node SDK?
            Asked 2021-Feb-02 at 02:24

            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:

            ...

            ANSWER

            Answered 2021-Feb-02 at 02:24

            Node SDK

            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.

            JAVA SDK

            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

            Source https://stackoverflow.com/questions/65956691

            QUESTION

            Store non-strings in Hyperledger Fabric 1.4
            Asked 2020-Jun-03 at 19:30

            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.

            ...

            ANSWER

            Answered 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).

            Source https://stackoverflow.com/questions/62150038

            QUESTION

            Hyperledger Fabric API returns a buffer type data, how do i convert buffer to string of this data in javascript
            Asked 2020-May-25 at 06:49

            i am building a blockchain on hyperledger fabric (node.js SDK).

            https://hyperledger.github.io/fabric-sdk-node/release-1.4/global.html#BlockchainInfo__anchor

            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.

            ...

            ANSWER

            Answered 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 currentBlockHash.toString().

            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 currentBlockHash.toString('hex')

            See here for more information on Buffers: https://nodejs.org/docs/latest-v10.x/api/buffer.html

            Source https://stackoverflow.com/questions/61649956

            QUESTION

            Hyperledger Fabric 2.0, where is Fab Token source code?
            Asked 2020-May-06 at 13:50

            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:

            https://fabric-sdk-node.github.io/master/tutorial-fabtoken.html

            https://gerrit.hyperledger.org/r/c/fabric/+/32979

            but they don't works.

            Thanks

            FINAL UPDATE (for other users)

            https://github.com/hyperledger/fabric/tree/v2.0.0-alpha/token

            this is the code of FabToken

            ...

            ANSWER

            Answered 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.

            Source https://stackoverflow.com/questions/60111228

            QUESTION

            How can I produce a SKI from RSA public Key in node js?
            Asked 2020-Mar-02 at 07:58

            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!

            Thanks!

            ...

            ANSWER

            Answered 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:

            Source https://stackoverflow.com/questions/60449571

            QUESTION

            Hyperledger Fabric - Update a channel config by adding a new Org
            Asked 2020-Jan-20 at 10:10

            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.

            Using this tutorial and some guidance from this question, I have the following code:

            ...

            ANSWER

            Answered 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

            Source https://stackoverflow.com/questions/59795992

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install fabric-sdk-node

            To build and test, the following pre-requisites must be installed first:.
            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)

            Support

            The SDK has support for Hardware Security Module (HSM) via PKCS #11 interface. See the test README for details of how to run HSM tests locally.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/hyperledger/fabric-sdk-node.git

          • CLI

            gh repo clone hyperledger/fabric-sdk-node

          • sshUrl

            git@github.com:hyperledger/fabric-sdk-node.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Reuse Pre-built Kits with fabric-sdk-node

            Consider Popular Blockchain Libraries

            bitcoin

            by bitcoin

            go-ethereum

            by ethereum

            lerna

            by lerna

            openzeppelin-contracts

            by OpenZeppelin

            bitcoinbook

            by bitcoinbook

            Try Top Libraries by hyperledger

            fabric

            by hyperledgerGo

            fabric-samples

            by hyperledgerTypeScript

            sawtooth-core

            by hyperledgerPython

            blockchain-explorer

            by hyperledgerJavaScript

            besu

            by hyperledgerJava