【发布时间】: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