【发布时间】:2018-06-12 07:46:37
【问题描述】:
我要使用sawtooth-sdk,以及引导码(https://sawtooth.hyperledger.org/docs/core/releases/latest/_autogen/sdk_submit_tutorial_js.html):
const {createContext, CryptoFactory} = require('sawtooth-sdk/signing')
const context = createContext('secp256k1')
const privateKey = context.newRandomPrivateKey()
const signer = CryptoFactory(context).newSigner(privateKey)
但错误:
TypeError: Class constructor CryptoFactory cannot be invoked without 'new'
【问题讨论】:
-
从错误信息来看,链接页面是错误的,错误是明确告诉你该怎么做。你试过这样做吗?
-
它看起来像一个类,你必须这样做: const factory = new CryptoFactory(context); const signer = facory.newSigner(privateKey);
-
const signer = new CryptoFactory(context).newSigner(privateKey)
标签: javascript node.js ecmascript-6 ecmascript-5 hyperledger-sawtooth