@huma-finance/permissionless-sdk 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/examples/getBalance.ts +33 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Connection, Keypair } from "@solana/web3.js";
|
|
2
|
+
import { PermissionlessClient, SolanaChainEnum } from "../src";
|
|
3
|
+
import { DepositMode } from "../src/types/metadata";
|
|
4
|
+
import dotenv from "dotenv";
|
|
5
|
+
|
|
6
|
+
dotenv.config();
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const connection = new Connection(process.env.RPC_URL!);
|
|
10
|
+
const client = new PermissionlessClient(connection, SolanaChainEnum.DEVNET);
|
|
11
|
+
|
|
12
|
+
const key = Keypair.fromSecretKey(
|
|
13
|
+
new Uint8Array(JSON.parse(process.env.PRIVATE_KEY!))
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
console.log("Getting locked balance for", key.publicKey.toString());
|
|
17
|
+
const data = await client.getLockedBalance(
|
|
18
|
+
key.publicKey,
|
|
19
|
+
DepositMode.CLASSIC
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
console.log(data.toString());
|
|
23
|
+
|
|
24
|
+
console.log("Getting unlocked balance for", key.publicKey.toString());
|
|
25
|
+
const unlockedData = await client.getUnlockedBalance(
|
|
26
|
+
key.publicKey,
|
|
27
|
+
DepositMode.CLASSIC
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
console.log(unlockedData.toString());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
main();
|