所以这是错误'\节点模块@散列图\sdk\lib\通道\节点通道.cjs:92 },10_000);
我只是建立了一个基本的连接来获取我的账户余额。下面是我的代码:
const { Client, AccountBalanceQuery } = require("@hashgraph/sdk");
require("dotenv").config();
async function main() {
// Grab your Hedera account ID and Key
const myAccountId = process.env.MY_ACCOUNT_ID;
const myPrivateKey = process.env.MY_PRIVATE_KEY;
// throw an error if you couldn't get the id
if (myAccountId == null || myPrivateKey == null ) {
throw new Error("Environment variables must be present");
}
console.log("I made it this far");
// connect to the hedera network
const client = Client.forTestnet();
client.setOperator(myAccountId, myPrivateKey);
// Now the connection to the hedera network is established
// get your balance
const balance = await new AccountBalanceQuery()
.setAccountId(myAccountId)
.execute(client)
console.log(`${myAccountId} balance = ${balance.value()}`);
}
main();
1条答案
按热度按时间flvlnr441#
你有关于你得到的错误的更详细的信息吗,我想不仅仅是一行,很难确定问题是什么。
删除node_modules并运行
npm install
或yarn install
也可能有所帮助。