MetaplexTokenMetaDataProgram.utilize constructor

MetaplexTokenMetaDataProgram.utilize({
  1. required SolAddress metadata,
  2. required SolAddress tokenAccount,
  3. required SolAddress mint,
  4. required SolAddress useAuthority,
  5. required SolAddress owner,
  6. required MetaplexTokenMetaDataUtilizeLayout layout,
  7. SolAddress tokenProgram = SPLTokenProgramConst.tokenProgramId,
  8. SolAddress ataProgram = AssociatedTokenAccountProgramConst.associatedTokenProgramId,
  9. SolAddress systemProgram = SystemProgramConst.programId,
  10. SolAddress rent = SystemProgramConst.sysvarRentPubkey,
  11. SolAddress? useAuthorityRecord,
  12. SolAddress? burner,
})

Implementation

factory MetaplexTokenMetaDataProgram.utilize({
  required SolAddress metadata,
  required SolAddress tokenAccount,
  required SolAddress mint,
  required SolAddress useAuthority,
  required SolAddress owner,
  required MetaplexTokenMetaDataUtilizeLayout layout,
  SolAddress tokenProgram = SPLTokenProgramConst.tokenProgramId,
  SolAddress ataProgram =
      AssociatedTokenAccountProgramConst.associatedTokenProgramId,
  SolAddress systemProgram = SystemProgramConst.programId,
  SolAddress rent = SystemProgramConst.sysvarRentPubkey,
  SolAddress? useAuthorityRecord,
  SolAddress? burner,
}) {
  if (burner != null) {
    if (useAuthorityRecord == null) {
      throw MessageException(
          "When providing 'burner' then 'accounts.useAuthorityRecord' need(s) to be provided as well.");
    }
  }
  return MetaplexTokenMetaDataProgram(keys: [
    metadata.toWritable(),
    tokenAccount.toWritable(),
    mint.toWritable(),
    useAuthority.toSignerAndWritable(),
    owner.toReadOnly(),
    tokenProgram.toReadOnly(),
    ataProgram.toReadOnly(),
    systemProgram.toReadOnly(),
    rent.toReadOnly(),
    if (useAuthorityRecord != null) useAuthorityRecord.toWritable(),
    if (burner != null) burner.toReadOnly()
  ], programId: MetaplexTokenMetaDataProgramConst.programId, layout: layout);
}