What is @metaplex-foundation/mpl-token-metadata?
@metaplex-foundation/mpl-token-metadata is an npm package that provides tools and utilities for interacting with token metadata on the Solana blockchain. It is part of the Metaplex ecosystem, which is designed to facilitate the creation, management, and trading of NFTs and other digital assets on Solana.
What are @metaplex-foundation/mpl-token-metadata's main functionalities?
Create Metadata
This feature allows you to create a new metadata account for a token on the Solana blockchain. The code sample demonstrates how to use the `createCreateMetadataAccountV2Instruction` function to set up the necessary parameters for creating metadata.
const { createCreateMetadataAccountV2Instruction } = require('@metaplex-foundation/mpl-token-metadata');
const createMetadata = (metadataAccount, mint, mintAuthority, payer, updateAuthority, metadataData) => {
return createCreateMetadataAccountV2Instruction({
metadata: metadataAccount,
mint,
mintAuthority,
payer,
updateAuthority,
metadataData,
});
};
Update Metadata
This feature allows you to update the metadata of an existing token. The code sample shows how to use the `createUpdateMetadataAccountV2Instruction` function to update the metadata with new information.
const { createUpdateMetadataAccountV2Instruction } = require('@metaplex-foundation/mpl-token-metadata');
const updateMetadata = (metadataAccount, updateAuthority, metadataData) => {
return createUpdateMetadataAccountV2Instruction({
metadata: metadataAccount,
updateAuthority,
metadataData,
});
};
Verify Collection
This feature allows you to verify a collection of NFTs. The code sample demonstrates how to use the `createVerifyCollectionInstruction` function to verify that a token belongs to a specific collection.
const { createVerifyCollectionInstruction } = require('@metaplex-foundation/mpl-token-metadata');
const verifyCollection = (metadataAccount, collectionAuthority, collectionMint) => {
return createVerifyCollectionInstruction({
metadata: metadataAccount,
collectionAuthority,
collectionMint,
});
};
0