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
mpl-token-metadata
This package contains the token vault contract SDK code.
API Docs
Find the token-metadata API docs published here.
Installation
npm install @metaplex-foundation/mpl-token-metadata --save
This will use the new auto-generated API. If you want to use the old deprecated API, you can use the following:
npm install @metaplex-foundation/mpl-token-metadata@^1.2 --save
Alternatively, if you'd like to start using the new API but still have access to the deprecated one, you may use the following:
npm install @metaplex-foundation/mpl-token-metadata@~2.0 --save
And use the deprecated API explicitly like so:
import { deprecated } from "@metaplex-foundation/mpl-token-metadata";
Developing
In order to update the generated SDK when the rust contract was updated please run:
yarn gen:api
and then update the wrapper code and tests.
LICENSE
Apache v2.0