SPLTokenProgram.initializeAccount2 constructor

SPLTokenProgram.initializeAccount2({
  1. required SPLTokenInitializeAccount2Layout layout,
  2. required SolAddress account,
  3. required SolAddress mint,
  4. SolAddress programId = SPLTokenProgramConst.tokenProgramId,
})

Like InitializeAccount, but the owner pubkey is passed via instruction data rather than the accounts list. This variant may be preferable when using Cross Program Invocation from an instruction that does not need the owner's AccountInfo otherwise.

Implementation

factory SPLTokenProgram.initializeAccount2(
    {required SPLTokenInitializeAccount2Layout layout,

    /// The account to initialize.
    required SolAddress account,

    /// The mint this account will be associated with.
    required SolAddress mint,
    SolAddress programId = SPLTokenProgramConst.tokenProgramId}) {
  return SPLTokenProgram(
      layout: layout,
      keys: [
        account.toWritable(),
        mint.toReadOnly(),
        SystemProgramConst.sysvarRentPubkey.toReadOnly(),
      ],
      programId: programId);
}