forked from hashgraph/hedera-sdk-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-account-info.js
53 lines (42 loc) · 1.26 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
47
48
49
50
51
52
53
import { Wallet, LocalProvider, AccountInfoQuery, Hbar } from "@hashgraph/sdk";
import dotenv from "dotenv";
dotenv.config();
async function main() {
if (
process.env.OPERATOR_ID == null ||
process.env.OPERATOR_KEY == null ||
process.env.HEDERA_NETWORK == null
) {
throw new Error(
"Environment variables OPERATOR_ID, HEDERA_NETWORK, and OPERATOR_KEY are required.",
);
}
const provider = new LocalProvider();
const wallet = new Wallet(
process.env.OPERATOR_ID,
process.env.OPERATOR_KEY,
provider,
);
try {
const info = await new AccountInfoQuery()
.setAccountId(wallet.getAccountId())
.setQueryPayment(new Hbar(1))
.executeWithSigner(wallet);
console.log(
`info.key = ${info.key.toString()}`,
);
console.log(
`info.isReceiverSignatureRequired =`,
info.isReceiverSignatureRequired,
);
console.log(
`info.expirationTime = ${info.expirationTime
.toDate()
.toString()}`,
);
} catch (error) {
console.error(error);
}
provider.close();
}
void main();