Query Nonce

import { PublicKey, NonceAccount } from "@solana/web3.js";
import { CONNECTION } from "../../../helper/const";

// query nonce account

async function main() {
  let nonceAccountPubkey = new PublicKey("2ZKe8GmRAqFRj3AvVSFBTLHNNrH1uB23hwjHV3CzJGmf");
  let accountInfo = await CONNECTION.getAccountInfo(nonceAccountPubkey);
  let nonceAccount = NonceAccount.fromAccountData(accountInfo.data);
  console.log(`auth: ${nonceAccount.authorizedPubkey.toBase58()}`)
  console.log(`nonce: ${nonceAccount.nonce}`)
  console.log(`fee calculator: ${nonceAccount.feeCalculator}`)
}

main().then(
  () => process.exit(),
  (err) => {
    console.error(err);
    process.exit(-1);
  }
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Last Updated: 9/23/2022, 6:56:02 PM
Contributors: Yihau Chen