Unable to read values from contract deployed in hyperledger blockchain -
i have set hyperledger blockchain locally. run hyperledger bc service within docker container. able bring node successfully, able deploy , write bc using sample contract.
but couldnt read data block chain. below error message bc throws. can pls guide what's wrong here ?
[ibc-js] deploy chaincode - complete {"query":{},"invoke":{},"details":{"deployed_name":"c123c14a65a511ee79e2a41b23726f473478d002064c01c3ce035cffa1229af083d73f1db220fc2f267b9ae31d66ce2e10113548e7abdf8812986ac3c5770a9c","func":{"invoke":["init","write"],"query":["read"]},"git_url":"https://github.com/ibm-blockchain/learn-chaincode/finished","options":{"quiet":true,"timeout":60000,"tls":false},"peers":[{"name":"vp0-vp0...:49155","api_host":"127.0.0.1","api_port":49155,"id":"vp0","tls":false}],"timestamp":1470146338831,"users":[],"unzip_dir":"learn-chaincode-master/finished","version":"github.com/hyperledger/fabric/core/chaincode/shim","zip_url":"https://github.com/ibm-blockchain/learn-chaincode/archive/master.zip"}} sdk has deployed code , waited [ibc-js] write - success: { jsonrpc: '2.0', result: { status: 'ok', message: '8b340e92-f96f-41f6-9b15-6ccb23304360' }, id: 1470146405598 } write response: { jsonrpc: '2.0', result: { status: 'ok', message: '8b340e92-f96f-41f6-9b15-6ccb23304360' }, id: 1470146405598 } [ibc-js] read - success: { jsonrpc: '2.0', error: { code: -32003, message: 'query failure', data: 'error when querying chaincode: error:failed launch chaincode spec(could not deployment transaction c123c14a65a511ee79e2xxxxxxxxxxxxxxxxe7abdf8812986ac3c5770a9c - ledgererror - resourcenotfound: ledger: resource not found)' }, id: 1470146405668 } read response: null { name: 'query() resp error', code: 400, details: { code: -32003, message: 'query failure', data: 'error when querying chaincode: error:failed launch chaincode spec(could not deployment transaction c123c14a65a511ee79e2xxxxxxxxxxxxxxxxe7abdf8812986ac3c5770a9c - ledgererror - resourcenotfound: ledger: resource not found)' } }
i have used ibm blockchain js interacting w/ go contract. below node js code
// step 1 ================================== var ibc1 = require('ibm-blockchain-js'); var ibc = new ibc1(/*logger*/); //you can pass logger such winston here - optional var chaincode = {}; // ================================== // configure ibc-js sdk // ================================== var options = { network:{ peers: [{ "api_host": "127.0.0.1", "api_port": 49155, //"api_port_tls": 49157, "id": "vp4" }], users: null, options: {quiet: true, tls:false, maxretry: 1} }, chaincode:{ zip_url: 'https://github.com/ibm-blockchain/learn-chaincode/archive/master.zip', unzip_dir: 'learn-chaincode-master/finished', git_url: 'https://github.com/ibm-blockchain/learn-chaincode/finished' } }; // step 2 ================================== ibc.load(options, cb_ready); // step 3 ================================== function cb_ready(err, cc){ //response has chaincode functions chaincode = cc; console.log(json.stringify(cc)); chaincode.deploy('init', ['hi hyperledger'], null, cb_deployed); // step 5 ================================== function cb_deployed(){ console.log(json.stringify(chaincode)); console.log('sdk has deployed code , waited'); console.log('******** writing chaincode **********'); chaincode.invoke.write(["mykey","hi ledger systems"],function(err,data){ console.log('write response:', data); readdata(); }); } function readdata() { console.log('\n\n**** waiting 7 seconds before reading **** \n\n'); settimeout(function () { console.log('\n\n**** start reading **** \n\n'); chaincode.invoke.read(["mykey"],function(err,data){ console.log('read response:', data); }); }, 7000) } }
Comments
Post a Comment