0

我使用 Node.js API 编写了我的链代码,现在我正在尝试实例化。

图片:超级账本/fabric-peer:1.4.5

我的 package.json 有以下来源:

{
    "name": "democontract",
    "version": "1.0.0",
    "description": "Document Contract",
    "main": "index.js",
    "engines": {
        "node": ">=8.4.0",
        "npm": ">=5.3.0"
    },
    "scripts": {
        "lint": "eslint .",
        "pretest": "npm run lint",
        "start": "fabric-chaincode-node start",
        "mocha": "mocha test --recursive"
    },
    "engine-strict": true,
    "license": "Apache-2.0",
    "private": true,
    "dependencies": {
        "mkdirp": ">=0.5.5",
        "openpgp": "^4.10.0",
        "fabric-chaincode-api": "^1.4.0",
        "fabric-shim": "^1.4.0"
    },
    "devDependencies": {
        "chai": "^4.1.2",
        "chai-as-promised": "^7.1.1",
        "eslint": "^4.19.1",
        "mocha": "^5.2.0",
        "nyc": "^12.0.2",
        "sinon": "^6.0.0",
        "sinon-chai": "^3.2.0"
    }
}

但是当我调用 CLI 容器来实例化链码(演示合同)时:

peer chaincode instantiate -C $CHANNELNAME -n $CHCODENAME -v $CHCODEVERSION -o $ORDERERNAME \
    -c '{"Args":["ContractDocument:instantiate"]}' \
    -P "OR('OrdererMSP.admin','Org1MSP.admin','Org1MSP.peer','Org1MSP.member')" \
    --tls --cafile $ORDERER_TLSCACERT --tlsRootCertFiles $CORE_PEER_TLS_ROOTCERT_FILE

我在 PEER 容器中收到后续错误,并且链代码无法实例化。

我不知道如何摆脱这种错误状况。拜托,你能帮帮我吗?

[endorser] SimulateProposal -> ERRO 050 [devchannel][bef25398] failed to invoke chaincode name:"lscc" , error: Failed to generate platform-specific docker build: 
Error returned from build: 1 "npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. 
Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm ERR! code E404
**npm ERR! 404 Not Found - GET https://registry.npmjs.org/fabric-chaincode-api - Not found**
npm ERR! 404 
npm ERR! 404  'fabric-chaincode-api@^1.4.0' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'output'
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-05-18T19_31_20_461Z-debug.log
"
error starting container
error starting container

问候, Magno A. Cavalcante

4

2 回答 2

0

您可能正在使用不兼容的节点 js 版本。请使用超级账本结构版本检查节点 js 的支持版本。

于 2020-05-24T12:47:11.807 回答
0

问题在package.json内部。

代码片段错误:

"dependencies": {
    "mkdirp": ">=0.5.5",
    "openpgp": "^4.10.0",
    "fabric-chaincode-api": "^1.4.0",
    "fabric-shim": "^1.4.0"
},

正确的代码片段是:

"dependencies": {
    "mkdirp": ">=0.5.5",
    "openpgp": "^4.10.0",
    "fabric-contract-api": "^1.4.3",
    "fabric-shim": "^1.4.3"
},

fabric-chaincode-api更改为fabric-contract-api

我参考 URL https://hyperledger.github.io/fabric-chaincode-node/master/api/tutorial-using-contractinterface.html中描述的包来编写我的 package.json 。

有关将来的参考资料,请参阅以下 URL:

于 2020-05-26T15:41:16.647 回答