0

So this is the error `\node_modules@hashgraph\sdk\lib\channel\NodeChannel.cjs:92 }, 10_000);

I'm just setting up a basic connection to get the balance of my account. Here is my code:

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();
Rocky Singh
  • 25
  • 1
  • 5
  • Hey Rocky Singh, I've been following along with the examples as well and the return I'm getting is a bit different. I've been following the documentation on github: https://github.com/hashgraph/hedera-docs/blob/master/tutorials/getting-started-javascript.md, which uses a different call. I'm not well versed in writing code in JS and this is my first foray into Hedera so I am out of my elelment. – Rsp8 May 28 '22 at 19:03

1 Answers1

0

do you have more detail on the error you're getting, I presume there's more to it than a single line ? It's pretty hard to identify what the issue might be with just that.

Deleting node_modules and running npm install or yarn install may also help just in case.

Greg Scullard
  • 241
  • 1
  • 10