建议和反馈

请填写你的反馈内容

问答 > 超级账本 > 问答详情
求助中

无法从超级边界区块链中部署的合同中读取值10LK

我在本地设置了超级边界区块链。我在docker容器中运行hyperledger bc服务。我能够成功启动节点,能够使用示例合同部署和写入bc 

但无法从区块链中读回数据。以下是bc抛出的错误消息。任何人都可以指导这里有什么问题吗?

    [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 and 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 to launch chaincode spec(Could not get deployment transaction for 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 to launch chaincode spec(Could not get deployment transaction for c123c14a65a511ee79e2xxxxxxxxxxxxxxxxe7abdf8812986ac3c5770a9c - LedgerError - ResourceNotFound: ledger: resource not found)' } }

我使用IBM Blockchain JS与go合同进行交互。下面是节点js代码

// Step 1 ==================================var Ibc1 = require('ibm-blockchain-js');var ibc = new Ibc1(/*logger*/);             //you can pass a logger such as winston here - optionalvar 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 functionschaincode = 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 and waited');
    console.log('******** Writing to chaincode Now **********');
    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)}
  }


2019-07-11
0
请先登陆或注册

暂无回答!

邀请

感谢您的善举,每一次解答会成为新人的灯塔,回答被采纳后获得20算力和相应的LK币奖励