我想使用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'
答案 0 :(得分:1)
如错误所述,您应该更改:
const signer = CryptoFactory(context).newSigner(privateKey)
为:
const signer = (new CryptoFactory(context)).newSigner(privateKey)