npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hfc-chain

v0.6.5

Published

The Hyperledger Fabric Client SDK (HFC) provides a powerful and easy to use API to interact with a Hyperledger Fabric blockchain.

Downloads

7

Readme

Hyperledger Fabric Client SDK for Node.js

Overview

The Hyperledger Fabric Client SDK (HFC) provides a powerful and easy to use API to interact with a Hyperledger Fabric blockchain from a Node.js application. It provides a set of APIs to register and enroll new network clients, to deploy new chaincodes to the network, and to interact with existing chaincodes through chaincode function invocations and queries.

To view the complete Node.js SDK documentation, additional usage samples, and getting started materials please visit the Hyperledger Fabric SDK documentation page.

Installation

If you are interfacing with a network running the Hyperledger Fabric v0.5-developer-preview branch, you must use the hfc version 0.5.x release and install it with the following command:

npm install [email protected]

For networks running newer versions of the Hyperledger Fabric, please install the version of hfc that corresponds to the same version of the Fabric code base. For example, for the Fabric v0.6 branch install hfc with the following command:

npm install [email protected]

Usage

Terminology

In order to transact on a Hyperledger blockchain, you must first have an identity which is both registered and enrolled. Registration means issuing a user invitation to join a blockchain network. Enrollment means accepting a user invitation to join a blockchain network.

In the current Hyperleger Fabric implementation, the administative user admin is already registered on the network by the virtue of the fact that their user ID and password pair are already added to the membership services server confiruation file, membersrvc.yaml. Therefore, the admin user must only enroll to be able to transact on the network. After enrollment, the administrative user is then able to register and enroll new users, in the role of a registrar. New users are added to the network programmatically, through the HFC chain.registerAndEnroll API.

Example

An example presented in the SDK documentation demonstrated a typical application using the hfc.

The application sets up a target for the membership service server and enrolls the admin user. Subsequently, the admin user is set as the registrar user and registers and enrolls a new member, JohnDoe. The new member, JohnDoe, is then able to transact on the blockchain by deploying a chaincode, invoking a chaincode function, and querying chaincode state.

Chaincode Deployment

Chaincode may be deployed in development mode or network mode. Development mode refers to running the chaincode as a stand alone process outside the network peer. This approach is useful while doing chaincode development and testing. The approach is described here. Network mode refers to packaging the chaincode and its dependencies and subsequently deploying the package to an existing network as a Docker container. To have the chaincode deployment with hfc succeed in network mode, you must properly set up the chaincode project and its dependencies. The instructions for doing so can be found in the Chaincode Deployment section of the Node.js SDK documentation page.

Enabling TLS

If you wish to enable TLS connection between the member services, the peers, and the chaincode container, please see the Enabling TLS section within the Node.js SDK documentation.

Objects, Classes, And Interfaces

HFC is written primarily in Typescript and is object-oriented. The source can be found in the fabric/sdk/node directory of the Hyperledger Fabric project. To better understand the object hierarchy, please read the high-level descriptions of the HFC objects (classes and interfaces) in the HFC Objects section within the Node.js SDK documentation. You can also build the complete reference documentation locally by following the instructions here.

Unit Tests

HFC includes a set of unit tests implemented with the tape framework. Currently, the unit tests are designed to run inside the Hyperledger Fabric Vagrant development environment. To run the unit tests, first set up the Hyperledger Fabric Vagrant development environment per the instructions here.

Launch the Vagrant VM and log into the VM by executing the following command:

vagrant ssh

Run the unit tests within the Vagrant environment with the following commands:

cd $GOPATH/src/github.com/hyperledger/fabric
make node-sdk-unit-tests

The following are brief descriptions of each of the unit tests that are being run.

registrar

The registrar.js test case exercises registering users with the membership services server. It also tests registering a designated registrar user which can then register additional users.

chain-tests

The chain-tests.js test case exercises the chaincode_example02.go chaincode when it has been deployed in both development mode and network mode.

asset-mgmt

The asset-mgmt.js test case exercises the asset_management.go chaincode when it has been deployed in both development mode and network mode.

asset-mgmt-with-roles

The asset-mgmt-with-roles.js test case exercises the asset_management_with_roles.go chaincode when it has been deployed in both development mode and network mode.

Basic Troubleshooting

Keep in mind that you can perform the enrollment process with the membership services server only once, as the enrollmentSecret is a one-time-use password. If you have performed a user registration/enrollment with the membership services and subsequently deleted the crypto tokens stored on the client side, the next time you try to enroll, errors similar to the ones below will be seen.

Error: identity or token do not match
Error: user is already registered

To address this, remove any stored crypto material from the CA server by following the instructions here. You will also need to remove any of the crypto tokens stored on the client side by deleting the KeyValStore directory. That directory is configurable and is set to /tmp/keyValStore within the unit tests.

Support

We use Hyperledger Slack for communication regarding the SDK and any potential issues. Please join SDK related channels on Slack such as #fabric-sdk and #nodesdk. If you would like to file a bug report or submit a request for a feature please do so on Jira here.

Contributing

We welcome any contributions to the Hyperledger Fabric Node.js SDK project. If you would like to contribute please read the contribution guidelines here for more information.

License

Contributed to the Hyperledger Project under the Apache Software License 2.0.