-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_admin.js
More file actions
27 lines (22 loc) · 1002 Bytes
/
fetch_admin.js
File metadata and controls
27 lines (22 loc) · 1002 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
const { Connection, PublicKey } = require('@solana/web3.js');
const anchor = require('@coral-xyz/anchor');
const connection = new Connection("https://api.devnet.solana.com");
const programId = new PublicKey("2yx2FXwxyskf3qhrknysyqNTuXXVsyC1nxyjuLUrVQuJ");
async function main() {
const globalStatePDA = PublicKey.findProgramAddressSync(
[Buffer.from("global_state")],
programId
)[0];
console.log("Global State PDA:", globalStatePDA.toBase58());
const accountInfo = await connection.getAccountInfo(globalStatePDA);
if (accountInfo) {
// IDL says admin is the first pubkey after the discriminator
// Discriminator is 8 bytes. Pubkey is 32 bytes.
const adminPubkeyBytes = accountInfo.data.slice(8, 40);
const adminPubkey = new PublicKey(adminPubkeyBytes);
console.log("Admin Pubkey in Global State:", adminPubkey.toBase58());
} else {
console.log("Global state not found!");
}
}
main().catch(console.error);