Node.js SDK and Client Application

Q

What is Node.js SDK and how to use it to write client applications?

✍: FYIcenter.com

A

Hyperledger Fabric Node.js SDK is a set of libraries that allows you to write client applications to interact with chaincode in Node.js language.

A Hyperledger Fabric network can be viewed as virtual operating system. Once it is up and running, client applications can be developed to interact with it in different programming languages.

The Node.js SDK is designed to help to develop such a client application quickly in Node.js language. The Node.js SDK offers APIs for you to:

  • Create channels
  • Ask peer nodes to join the channel
  • Install chaincodes in peers
  • Instantiate chaincodes in a channel
  • Invoke transactions by calling the chaincode
  • Query the ledger for transactions or blocks

More precisely, Node.js SDK provide 3 API modules with the following features different features:

1. fabric-network:

  • Submitting transactions to a smart contract.
  • Querying a smart contract for the latest application state.

2.fabric-client:

  • create a new channel
  • send channel information to a peer to join
  • install chaincode on a peer
  • instantiate chaincode in a channel, which involves two steps: propose and transact
  • submitting a transaction, which also involves two steps: propose and transact
  • query a chaincode for the latest application state
  • various query capabilities: channel height; block-by-number; block-by-hash; all channels that a peer is part of; all installed chaincodes in a peer; all instantiated chaincodes in a channel; transaction-by-id; channel configuration data.
  • monitoring events: connect to a peer's event stream; listen on block events; listen on transactions events and find out if the transaction was successfully committed to the ledger or marked invalid; listen on custom events produced by chaincodes.
  • serializable User object with signing capabilities hierarchical configuration settings with multiple layers of overrides: files, environment variable, program arguments, in-memory settings logging utility with a built-in logger (winston) and can be overridden with a number of popular loggers including log4js and bunyan
  • pluggable CryptoSuite interface describe the cryptographic operations required for successful interactions with the Fabric. Two implementations are provided out of box: Software-based ECDSA and PKCS#11-compliant ECDSA.
  • pluggable State Store interface for persisting state caches such as users: File-based store; CouchDB-base store which works with both CouchDB database and IBM Cloudant.
  • customizable Crypto Key Store for any software-based cryptographic suite implementation
  • supports both TLS (grpcs://) or non-TLS (grpc://) connections to peers and orderers, see Remote which is the superclass for peers and orderers

3. fabric-ca-client:

  • register a new user
  • enroll a user to obtain the enrollment certificate signed by the Fabric CA
  • revoke an existing user by enrollment ID or revoke a specific certificate
  • customizable persistence store

For more information on Node.js SDK, see fabric-sdk-node.github.io Website.

 

FabricCAServices Node.js Class

Download and Install Java SDK

Interfaces to Communicate with Ledger Peer

⇑⇑ Hyperledger Tutorials

2020-02-07, 1177🔥, 0💬