assign static method

TransactionInstruction assign({
  1. required Pubkey accountPubkey,
  2. required Pubkey programId,
})

Generates a transaction instruction that assigns an account to a program.

Keys:

  • accountPubkey The public key of the account which will be assigned a new owner.

Data:

  • programId The public key of the program to assign as the owner.

Implementation

static TransactionInstruction assign({
  required final Pubkey accountPubkey,
  required final Pubkey programId,
}) {
  final List<AccountMeta> keys = [
    AccountMeta.signerAndWritable(accountPubkey),
  ];

  final List<Iterable<int>> data = [
    borsh.pubkey.encode(programId.toBase58()),
  ];

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