SPLTokenProgram.initializeAccount constructor

SPLTokenProgram.initializeAccount({
  1. required SolAddress account,
  2. required SolAddress mint,
  3. required SolAddress owner,
  4. SolAddress programId = SPLTokenProgramConst.tokenProgramId,
})

Initializes a new account to hold tokens. If this account is associated with the native mint then the token balance of the initialized account will be equal to the amount of SOL in the account. If this account is associated with another mint, that mint must be initialized before this command can succeed.

Implementation

factory SPLTokenProgram.initializeAccount(
    {
    /// The account to initialize.
    required SolAddress account,

    /// The mint this account will be associated with.
    required SolAddress mint,

    /// The new account's owner/multisignature.
    required SolAddress owner,
    SolAddress programId = SPLTokenProgramConst.tokenProgramId}) {
  return SPLTokenProgram(
      layout: SPLTokenInitializeAccountLayout(),
      keys: [
        account.toWritable(),
        mint.toReadOnly(),
        owner.toReadOnly(),
        SystemProgramConst.sysvarRentPubkey.toReadOnly(),
      ],
      programId: programId);
}