简体   繁体   中英

how to use node js SDK in hyperledger Fabric?

i have started a fabric 1.1 blockchain network with two orgs org1 and org2 and having two peers each with single orderer and certificate Authority. created a Channel and added peers to that and installed same chaincode on to 4 peers using Hyperledger composer with ConnectionProfiles.json, Now am confused of using NODE JS SDK :( wheteher to use (NODE JS SDK) to communicate to peers in the above (FABRIC 1.1 ) network created or it(node js SDK) is used to create channel & add peers Does node JS replaces the composer ?????

It is not compulsory that you need node sdk to connect with hyperledger. You can easily connect with hyperledger composer through node.Than you can easily write a node code to connect two Peers Easily

    var request = require('request');

var headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
};

var dataString = '{ \ 
   "$class": "test.User", \ 
   "uid": "01", \ 
   "firstName": "Prateek", \ 
   "lastName": "Tiwari", \ 
   "emailAddress": "prat%40", \ 
   "contactNo": "789", \ 
   "password": "7596.." \ 
 }';

var options = {
    url: 'http://localhost:3000/api/test.User',
    method: 'POST',
    headers: headers,
    body: dataString
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM