forked from hashgraph/hedera-sdk-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-account-info.js
46 lines (37 loc) · 1.06 KB
/
get-account-info.js
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
35
36
37
38
39
40
41
42
43
44
45
46
import {
Client,
AccountInfoQuery,
Hbar,
AccountId,
PrivateKey,
} from "@hashgraph/sdk";
import * as dotenv from "dotenv";
dotenv.config();
async function main() {
let client;
try {
client = Client.forName(process.env.HEDERA_NETWORK).setOperator(
AccountId.fromString(process.env.OPERATOR_ID),
PrivateKey.fromString(process.env.OPERATOR_KEY)
);
} catch (error) {
throw new Error(
"Environment variables HEDERA_NETWORK, OPERATOR_ID, and OPERATOR_KEY are required."
);
}
const info = await new AccountInfoQuery()
.setAccountId(client.operatorAccountId)
.setQueryPayment(new Hbar(1))
.execute(client);
console.log(`info.key = ${info.key.toString()}`);
console.log(
`info.isReceiverSignatureRequired =`,
info.isReceiverSignatureRequired
);
console.log(
`info.expirationTime = ${info.expirationTime
.toDate()
.toString()}`
);
}
void main();