调用.getReceipt()时,以下代码会引发错误. 请注意,交易本身是成功的.

    const hcsTopicCreateTx = await new TopicCreateTransaction()
        .freezeWith(client)
        .sign(operatorKey);
    const hcsTopicCreateTxResponse = await hcsTopicCreateTx.execute(client);
    const hcsTopicCreateReceipt = await hcsTopicCreateTxResponse.getReceipt();

这是错误:

file:///Users/user/code/hedera/hedera-code-snippets/hcs-topic-permissioned-write/node_modules/@hashgraph/sdk/src/Executable.js:518
                ? client._logger != null
                         ^
TypeError: Cannot read properties of undefined (reading '_logger')
    at TransactionReceiptQuery.execute (file:///Users/user/code/hedera/hedera-code-snippets/hcs-topic-permissioned-write/node_modules/@hashgraph/sdk/src/Executable.js:518:26)
    at TransactionResponse.getReceipt (file:///Users/user/code/hedera/hedera-code-snippets/hcs-topic-permissioned-write/node_modules/@hashgraph/sdk/src/transaction/TransactionResponse.js:81:54)
    at main (file:///Users/user/code/hedera/hedera-code-snippets/hcs-topic-permissioned-write/hcs-write.js:60:66)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

为什么_logger人失踪?

以下是client对象的初始化方式:

const client = Client.forTestnet().setOperator(operatorId, operatorKey);

还try 在client上手动初始化记录器,如下所示:

const client = Client.forTestnet().setOperator(operatorId, operatorKey);
client.setLogger(new Logger(LogLevel.Warn));

然而,同样的错误仍然存在.如何解决这个问题?

推荐答案

错误发生not,因为未设置记录器对象, 而是因为客户端对象未设置. 请注意,事务请求是getRecord请求中的different, 因此客户端对象也需要传递到其中.

下面的代码执行.getReceipt(client)(而不是.getReceipt()), 这不应该引发您的问题中描述的错误.

    const hcsTopicCreateTx = await new TopicCreateTransaction()
        .freezeWith(client)
        .sign(operatorKey);
    const hcsTopicCreateTxResponse = await hcsTopicCreateTx.execute(client);
    const hcsTopicCreateReceipt = await hcsTopicCreateTxResponse.getReceipt(client);

Javascript相关问答推荐

在JavaScript中对大型级联数组进行切片的最有效方法?

使用json文件字符串来enum显示类型字符串无法按照计算的enum成员值的要求分配给类型号

从WooCommerce Checkout Country字段重新排序国家,保持国家同步

Angular material 拖放堆叠的牌副,悬停时自动展开&

如何使用JavaScript将文本插入空div

google docs boldText直到按行执行应用脚本错误

屏幕右侧屏障上的产卵点""

S文本内容和值不必要的不同

第三方包不需要NODE_MODULES文件夹就可以工作吗?

一个实体一刀VS每个实体多刀S

是否可以将Select()和Sample()与Mongoose结合使用?

在Java脚本中录制视频后看不到曲目

JWT Cookie安全性

有没有办法通过使用不同数组中的值进行排序

用Reaction-RT-Chart创建实时条形图

我怎样才能点击一个元素,并获得一个与 puppeteer 师导航页面的URL?

为什么当雪碧的S在另一个函数中时,Phaser不能加载它?

使用Perl Selify::Remote::Driver执行Java脚本时出错

无法向甜甜圈图表上的ChartJSImage添加可见标签

找不到处于状态的联系人