assignWithSeed static method

TransactionInstruction assignWithSeed({
  1. required Pubkey accountPubkey,
  2. required Pubkey basePubkey,
  3. required String seed,
  4. 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:

  • basePubkey The base public key used to derive the address of the assigned account.
  • seed The seed used to derive the address of the assigned account.
  • programId The public key of the program to assign as the owner.

Implementation

static TransactionInstruction assignWithSeed({
  required final Pubkey accountPubkey,
  required final Pubkey basePubkey,
  required final String seed,
  required final Pubkey programId,
}) {
  final List<AccountMeta> keys = [
    AccountMeta.writable(accountPubkey),
    AccountMeta.signer(basePubkey),
  ];

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

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