[英]Is it possible to use external node module in our fabric chainCode/ smart contract?
I am trying to write a chainCode and for the implementation of logic, I need to use an external node package, which is not a part of fabric API.我正在尝试编写一个链代码,为了实现逻辑,我需要使用一个外部节点包,它不是结构 API 的一部分。 Is it possible to do that?
有可能这样做吗?
I've never seen a chainCode example, which requires an external node module.我从未见过需要外部节点模块的 chainCode 示例。 If you know an example please share with me.
如果你知道一个例子,请与我分享。
Also, if it is possible, I would like to know about the risks of doing that and what is the good design to minimize the risks.此外,如果可能的话,我想知道这样做的风险以及将风险降至最低的良好设计是什么。
'use strict' '使用严格'
const { Shim } = require('fabric-shim') const { Shim } = require('fabric-shim')
const path=require("path") const path=require("路径")
const fs=require('fs') const fs=require('fs')
const examplecc = require('./lib/examplecontract.js') const examplecc = require('./lib/examplecontract.js')
function main(){函数主(){
const tlsCertsPath=path.resolve(__dirname,"lib", "tls")
const tlsKey = fs.readFileSync( path.resolve(tlsCertsPath, "server.key"))
const tlsCert = fs.readFileSync(path.resolve(tlsCertsPath, "server.crt"))
const rootCert = fs.readFileSync(path.resolve(tlsCertsPath, "ca.crt"))
const config={
ccid:
"examplecc:1177322ea1cb10e56c4499016dsdb2fbf0be155660e97a38ca48de76326b12362", "examplecc:1177322ea1cb10e56c4499016dsdb2fbf0be155660e97a38ca48de76326b12362",
address: "0.0.0.0:9992"}
const server= Shim.server(new examplecc(),{
ccid: config.ccid,
address: config.address,
tlsProps: {
disabled: true,
key: tlsKey,
cert: tlsCert,
clientCACerts: rootCert,
}
} )
server.start().then((res)=>{
console.log("Server running successfully @" + config.address )
})
} }
main()主要的()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.