NameServiceProgram.create constructor

NameServiceProgram.create({
  1. required NameServiceCreateLayout layout,
  2. required SolAddress nameKey,
  3. required SolAddress nameOwnerKey,
  4. required SolAddress payerKey,
  5. SolAddress nameProgramId = NameServiceProgramConst.programId,
  6. SolAddress systemProgramId = SystemProgramConst.programId,
  7. SolAddress? nameClassKey,
  8. SolAddress? nameParent,
  9. SolAddress? nameParentOwner,
})

Create an empty name record

Implementation

factory NameServiceProgram.create({
  required NameServiceCreateLayout layout,

  /// Name record to be created (program-derived address)
  required SolAddress nameKey,

  /// Account owner
  required SolAddress nameOwnerKey,

  /// Funding account (must be a system account)
  required SolAddress payerKey,
  SolAddress nameProgramId = NameServiceProgramConst.programId,

  /// System program
  SolAddress systemProgramId = SystemProgramConst.programId,

  /// Account class
  SolAddress? nameClassKey,

  /// Parent name record
  SolAddress? nameParent,

  /// Owner of the parent name record.
  SolAddress? nameParentOwner,
}) {
  return NameServiceProgram(
    keys: [
      systemProgramId.toReadOnly(),
      payerKey.toSignerAndWritable(),
      nameKey.toWritable(),
      nameOwnerKey.toReadOnly(),
      nameClassKey?.toSigner() ?? SolAddress.defaultPubKey.toReadOnly(),
      nameParent?.toReadOnly() ?? SolAddress.defaultPubKey.toReadOnly(),
      if (nameParentOwner != null) nameParentOwner.toSigner(),
    ],
    programId: nameProgramId,
    layout: layout,
  );
}