Uploaded image for project: 'Fabric'
  1. Fabric
  2. FAB-2331

Fabric support for javascript chaincode



      Add support to allow chaincode to be written in javascript, specifically in the node.js execution environment.

      • A chaincode written in javascript is able to use the standard shim interface https://github.com/hyperledger/fabric/blob/release/core/chaincode/shim/interfaces.go, implemented in JS
      • follows the same lifecycle as golang and java: install -> instantiate -> upgrade
      • utilizes the "chaincode platform" framework based on docker, so that a javascript chaincode image is built by the peer based on a base image and dockerfile commands specific to the js chaincode execution environment
      • chaincodes written in javascript is able to use the standard require() to make use of npm modules
      • an optional package.json can accompany the chaincode to specify name, version, and most importantly external dependencies
      • during install, the chaincode's external dependencies can either be specified by the package.json, for which they will be installed when the chaincode docker image is being built by the peer, or they can be included in the chaincode package as part of the ChaincodeDeploymentSpec inside a "node_modules" folder. having this flexibility provides the balance b/w deterministic installs and light-weight code packages, and enables the developer to determine the optimal approach

      The implementation of this new capability will be split b/w two repositories:

      • fabric: enhancement to core/chaincode/chaincode_support.go to direct requests targeting the node.js chaincode to new platform handler, to be implemented in core/chaincode/platforms/node package
      • fabric-chaincode-node: will originally contain the shim implementation in node.js


        1. fab-2331.png
          651 kB
        2. js_examplecc.js
          1 kB
        3. jscc.diff
          42 kB

          Issue Links



              • Assignee:
                jimthematrix Jim Zhang
                Honglei Cong Honglei
                Anthony O'Dowd, Christopher Ferris, Clarity Zhang, Cong Honglei, Dan Selman, Gari Singh, Greg Haskins, Leonid Turnaev, Matthias Neugschwandtner, Qiang Wang, Rohit Mohta, Sandeep Pulluru, Yacov Manevich
              • Votes:
                6 Vote for this issue
                13 Start watching this issue


                • Created:

                  Time Tracking

                  Original Estimate - 14 weeks, 1 day
                  14w 1d
                  Remaining Estimate - 0 minutes
                  Time Spent - 14 weeks, 1 day
                  14w 1d