-
Notifications
You must be signed in to change notification settings - Fork 352
/
Copy pathall.en.ts
27 lines (24 loc) · 984 Bytes
/
all.en.ts
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
import { clusterApiUrl, Connection, PublicKey } from "@solana/web3.js";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
(async () => {
// connection
const connection = new Connection(clusterApiUrl("devnet"), "confirmed");
const owner = new PublicKey("G2FAbFQPFa5qKXCetoFZQEvF9BVvCKbvUZvodpVidnoY");
let response = await connection.getParsedTokenAccountsByOwner(owner, {
programId: TOKEN_PROGRAM_ID,
});
response.value.forEach((accountInfo) => {
console.log(`pubkey: ${accountInfo.pubkey.toBase58()}`);
console.log(`mint: ${accountInfo.account.data["parsed"]["info"]["mint"]}`);
console.log(
`owner: ${accountInfo.account.data["parsed"]["info"]["owner"]}`
);
console.log(
`decimals: ${accountInfo.account.data["parsed"]["info"]["tokenAmount"]["decimals"]}`
);
console.log(
`amount: ${accountInfo.account.data["parsed"]["info"]["tokenAmount"]["amount"]}`
);
console.log("====================");
});
})();