SPLTokenProgram.createNativeMint constructor

SPLTokenProgram.createNativeMint({
  1. required SolAddress payer,
  2. SolAddress nativeMintId = SPLTokenProgramConst.nativeMint2022,
  3. SolAddress programId = SPLTokenProgramConst.token2022ProgramId,
})

Creates the native mint.

Implementation

factory SPLTokenProgram.createNativeMint(
    {
    /// Funding account (must be a system account)
    required SolAddress payer,

    /// The native mint address
    SolAddress nativeMintId = SPLTokenProgramConst.nativeMint2022,
    SolAddress programId = SPLTokenProgramConst.token2022ProgramId}) {
  if (programId == SPLTokenProgramConst.tokenProgramId) {
    throw const SolanaPluginException(
        "Token program id does not support extensions");
  }
  return SPLTokenProgram(
      layout: SPLTokenCreateNativeMintLayout(),
      keys: [
        payer.toSignerAndWritable(),
        nativeMintId.toWritable(),
        SystemProgramConst.programId.toReadOnly()
      ],
      programId: programId);
}