【问题标题】:Invalid Private length Issue私人长度问题无效
【发布时间】:2023-01-25 07:35:06
【问题描述】:
 throw new _BadKeyError.default(`invalid private key length: ${data.length} bytes`);

设置测试环境时出现此错误

const { Client } = require("@hashgraph/sdk");
require("dotenv").config();

async function main() {

    //Grab your Hedera testnet account ID and private key from your .env file
    const myAccountId = process.env.MY_ACCOUNT_ID;
    const myPrivateKey = process.env.MY_PRIVATE_KEY;

    // If we weren't able to grab it, we should throw a new error
    if (myAccountId == null ||
        myPrivateKey == null ) {
        throw new Error("Environment variables myAccountId and myPrivateKey must be present");
    }

    // Create our connection to the Hedera network
    // The Hedera JS SDK makes this really easy!
    const client = Client.forTestnet();

    client.setOperator(myAccountId, myPrivateKey);
    console.log('success');
    client.close();
}
main();

上面的代码我运行并得到了错误。请有人检查

【问题讨论】:

    标签: hedera-hashgraph


    【解决方案1】:

    给出的错误消息让我认为您的私钥可能已关闭。仔细检查您的 .env 文件并确保您已正确输入您的私钥。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-24
      • 2013-02-06
      • 1970-01-01
      • 2015-11-14
      • 1970-01-01
      • 1970-01-01
      • 2016-05-11
      相关资源
      最近更新 更多