[英]Hyperledger Fabric / Nodejs - what's the difference between running a contract with node and fabric-chaincode-node
[英]Is it possible to use external node module in our fabric chainCode/ smart contract?
我正在嘗試編寫一個鏈代碼,為了實現邏輯,我需要使用一個外部節點包,它不是結構 API 的一部分。 有可能這樣做嗎?
我從未見過需要外部節點模塊的 chainCode 示例。 如果你知道一個例子,請與我分享。
此外,如果可能的話,我想知道這樣做的風險以及將風險降至最低的良好設計是什么。
'使用嚴格'
const { Shim } = require('fabric-shim')
const path=require("路徑")
const fs=require('fs')
const examplecc = require('./lib/examplecontract.js')
函數主(){
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",
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 )
})
}
主要的()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.