nonceWithdraw static method

TransactionInstruction nonceWithdraw({
  1. required Pubkey noncePubkey,
  2. required Pubkey authorizedPubkey,
  3. required Pubkey toPubkey,
  4. required bu64 lamports,
})

Generates a transaction instruction that withdraws lamports from a Nonce account.

Keys:

  • [w] noncePubkey The nonce account.
  • [s] authorizedPubkey The public key of the nonce authority.
  • [w] toPubkey The public key of the account which will receive the withdrawn nonce account balance.

Data:

  • lamports The mount of lamports to withdraw from the nonce account.

Implementation

static TransactionInstruction nonceWithdraw({
  required final Pubkey noncePubkey,
  required final Pubkey authorizedPubkey,
  required final Pubkey toPubkey,
  required final bu64 lamports,
}) {
  final List<AccountMeta> keys = [
    AccountMeta.writable(noncePubkey),
    AccountMeta.writable(toPubkey),
    AccountMeta(sysvarRecentBlockhashesPubkey),
    AccountMeta(sysvarRentPubkey),
    AccountMeta.signer(authorizedPubkey),
  ];

  final List<Iterable<int>> data = [
    borsh.u64.encode(lamports),
  ];

  return _instance.createTransactionIntruction(
    SystemInstruction.withdrawNonceAccount,
    keys: keys,
    data: data,
  );
}