-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountBalance.js
More file actions
34 lines (27 loc) · 833 Bytes
/
Copy pathAccountBalance.js
File metadata and controls
34 lines (27 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { AccountBalanceQuery, LocalProvider, Wallet } = require("@hashgraph/sdk");
const dotenv = require("dotenv");
dotenv.config();
async function main() {
if (process.env.OPERATOR_ID == null || process.env.OPERATOR_KEY == null) {
throw new Error(
"Environment variables OPERATOR_ID, and OPERATOR_KEY are required."
);
}
const wallet = new Wallet(
process.env.OPERATOR_ID,
process.env.OPERATOR_KEY,
new LocalProvider()
);
const balance = await new AccountBalanceQuery()
.setAccountId(wallet.getAccountId())
.executeWithSigner(wallet);
console.log(
`${wallet
.getAccountId()
.toString()} balance = ${balance.hbars.toString()}`
);
}
void main();
setTimeout(() => {
process.exit(0);
}, 3000);