简体   繁体   English

是否可以在我们的结构链代码/智能合约中使用外部节点模块?

[英]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.

相关问题 Hyperledger Fabric / Nodejs - 使用节点和fabric-chaincode-node运行合约有什么区别 - Hyperledger Fabric / Nodejs - what's the difference between running a contract with node and fabric-chaincode-node 是否可以使用节点 SDK 来 package Hyperledger Fabric 链码? - Is it possible to package the Hyperledger Fabric chaincode using the node SDK? 在 Hyperledger Fabric NodeJS 智能合约中实例化链码后,如何防止调用“init”函数? - How do you prevent the "init" function to be called after a chaincode has been instantiated in a Hyperledger Fabric NodeJS smart contract? Hyperledger Fabric Smart Contract的功能类型 - Type of functions for Hyperledger Fabric Smart Contract 使用节点SDK在Hyperledger Fabric上升级Chaincode - Upgrade Chaincode on hyperledger fabric using node sdk 在结构1.3的节点中实例化fabcar链码时出错 - Error in instantiating fabcar chaincode in node, fabric 1.3 使用节点的智能合约部署无法正常工作 - Smart contract deployment with node is not working 在Hyperledger Fabric NodeJS智能合约中,是否应将所有参数作为字符串传递? - In Hyperledger Fabric NodeJS smart contract, should all parameters be passed as a string? 在 Hyperledger Fabric 智能合约中,我如何打开日志记录? - In a Hyperledger Fabric Smart Contract how do I turn on logging? Node JS 与以太坊智能合约交互 - Node JS Interacting with Ethereum Smart Contract
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM