TokenInstruction.initializeAccount constructor

TokenInstruction.initializeAccount({
  1. required Ed25519HDPublicKey account,
  2. required Ed25519HDPublicKey mint,
  3. required Ed25519HDPublicKey owner,
})

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 TokenInstruction.initializeAccount({
  required Ed25519HDPublicKey account,
  required Ed25519HDPublicKey mint,
  required Ed25519HDPublicKey owner,
}) =>
    TokenInstruction._(
      accounts: [
        AccountMeta.writeable(pubKey: account, isSigner: true),
        AccountMeta.readonly(pubKey: mint, isSigner: false),
        AccountMeta.readonly(pubKey: owner, isSigner: false),
        AccountMeta.readonly(
          pubKey: Ed25519HDPublicKey.fromBase58(Sysvar.rent),
          isSigner: false,
        ),
      ],
      data: TokenProgram.initializeAccountInstructionIndex,
    );