getMetadata method

Future<Metadata?> getMetadata({
  1. required Ed25519HDPublicKey mint,
  2. Commitment commitment = Commitment.finalized,
})

Implementation

Future<Metadata?> getMetadata({
  required Ed25519HDPublicKey mint,
  Commitment commitment = Commitment.finalized,
}) async {
  final programAddress = await findMetaplexMetadataProgramAddress(mint);
  final account = await getAccountInfo(
    programAddress.toBase58(),
    encoding: Encoding.base64,
    commitment: commitment,
  ).value;
  if (account == null) {
    return null;
  }

  final data = account.data;

  return data is BinaryAccountData ? Metadata.fromBinary(data.data) : null;
}