
Print NFT with Umi
Print NFTs from the masterEdition using Umi and the mpl-token-metadata program.

CAVYAR AI
CAVYAR AI is in its earliest stages of development and the quality of generated descriptions will improve massively over time. At this stage, there is a risk of false information being generated.
This code snippet is used to print a non-fungible token (NFT) from a master edition using the Umi library and the mpl-token-metadata program. Here's a breakdown of what the code does:
-
Import necessary libraries:
createUmi
from@metaplex-foundation/umi-bundle-defaults
: This function is used to create an instance of the Umi library with default settings.generateSigner
andpublicKey
from@metaplex-foundation/umi
: These functions are used to generate a signer and retrieve the public key of an account.fetchMasterEditionFromSeeds
,mplTokenMetadata
,printV1
, andTokenStandard
from@metaplex-foundation/mpl-token-metadata
: These functions and constants are used for fetching master edition information, printing NFTs, and defining the token standard.
-
Create an instance of Umi:
umi = createUmi("https://api.mainnet-beta.solana.com", "processed").use(mplTokenMetadata())
: This creates an instance of Umi with the specified Solana API URL and enables the mplTokenMetadata plugin.
-
Define the master edition mint account:
masterEditionMint = publicKey("YourMasterEditionMint")
: This retrieves the public key of the master edition mint account, which represents the printable NFT.
-
Fetch the master edition account:
masterEdition = await fetchMasterEditionFromSeeds(umi, { mint: masterEditionMint })
: This fetches the master edition account using the Umi instance and the mint account address. It is used to set the edition number correctly by adding 1 to the current supply.
-
Generate signers and define the owner of the printed edition:
originalOwner = generateSigner(umi)
: This generates a signer for the original owner of the master edition. Only the original owner can print new editions.editionMint = generateSigner(umi)
: This generates a signer for the newly minted NFT edition.ownerOfThePrintedEdition = publicKey("YourPrintedEditionOwner")
: This retrieves the public key of the account that will receive the printed NFT.
-
Print the NFT:
await printV1(umi, { ... })
: This function is used to print the NFT. It takes several parameters, including the master token account owner, master edition mint, edition mint, edition token account owner, edition number, and token standard.sendAndConfirm(umi)
: This sends and confirms the transaction using the Umi instance.
Overall, this code snippet sets up the necessary configurations, fetches the master edition account, generates signers, and prints a new NFT edition using the Umi library and mpl-token-metadata program.
Ask

Soon™