0
votes

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

1
The chaincode is in effect your deployed smart contract and runs within a dockerized container . The SDK 'Hyperledger Fabric Client for Node.js' is for writing node.js APPLICATIONS (eg client app in your enterprise) to interact with the chaincode you installed on the blockchain network (eg. to instantiate/start the chaincode, send transaction invocations to it, and/or perform chaincode queries to it in the blockchain network). - Paul O'Mahony
You used H/L Composer as the vehicle to do the chaincode install via a composer network install (to install the NodeJS chaincode on the Fabric peers) . So now you know what they do - you probably you want to decide HOW you develop your chaincodes (ie business networks in Composer). Hyperledger Composer is a set of collaboration tools that's model driven, for building blockchain business networks (smart contracts) thats designed to make it easier and fast for business orgs and developers to create smart contracts (chaincodes) and blockchain applications to solve business problems. - Paul O'Mahony
Docs for both are here (Composer) hyperledger.org/projects/composer and (Fabric) hyperledger-fabric.readthedocs.io/en/release-1.2/… . They're different approaches. Goes without saying, the SDKs (whether its Fabric's or Composer's) , generally speaking, exist for developing/integrating client APPLICATIONS or interact with the deployed chaincodes on the blockchain network and manages the ledger state through transactions submitted by applications. - Paul O'Mahony
bt the chaincode deployed as .bna using composer network install has a different structure compared to installing chaincode with node js SDk is that so?? - Techie

1 Answers

0
votes

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);