CAVYAR

CAVYAR AI

Print NFT with Umi

Umi
Print NFT
Print
Mint NFT
Master Edition

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

import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; import { generateSigner, publicKey, } from "@metaplex-foundation/umi"; import { fetchMasterEditionFromSeeds, mplTokenMetadata, printV1, TokenStandard, } from "@metaplex-foundation/mpl-token-metadata"; const umi = createUmi("https://api.mainnet-beta.solana.com", "processed").use( mplTokenMetadata() ); const masterEditionMint = publicKey("YourMasterEditionMint"); // The mint account address of the printable NFT // Fetch master edition account to set the edition number correctly (supply + 1) const masterEdition = await fetchMasterEditionFromSeeds(umi, { mint: masterEditionMint, }); const originalOwner = generateSigner(umi); // The original owner of the master edition - Only the original owner can print new editions const editionMint = generateSigner(umi); // The newly generated mint account of the NFT to be printed const ownerOfThePrintedEdition = publicKey("YourPrintedEditionOwner"); // Will receive the printed NFT await printV1(umi, { masterTokenAccountOwner: originalOwner, masterEditionMint, editionMint, editionTokenAccountOwner: ownerOfThePrintedEdition, editionNumber: masterEdition.supply + 1n, tokenStandard: TokenStandard.NonFungible, }).sendAndConfirm(umi);

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:

  1. 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 and publicKey from @metaplex-foundation/umi: These functions are used to generate a signer and retrieve the public key of an account.
    • fetchMasterEditionFromSeeds, mplTokenMetadata, printV1, and TokenStandard from @metaplex-foundation/mpl-token-metadata: These functions and constants are used for fetching master edition information, printing NFTs, and defining the token standard.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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™

Created by:

Axax...GsG2

Give this snippet a feedback!

Published on

April 24, 2025

Want to support the author?