
Create Collection NFT with Umi
This code let's you create a collection NFT using the mpl-token-metadata-program. Collections are useful for grouping NFTs together. This again makes it easier to fetch the NFTs later on.

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 creates a collection NFT using the mpl-token-metadata-program. It uses the Umi library from the Metaplex Foundation to interact with the Solana blockchain. The code performs the following steps:
- Imports necessary functions and libraries from the Umi and mpl-token-metadata packages.
- Creates an instance of Umi using the
createUmi
function, specifying the Solana API endpoint and the processing mode. - Generates a signer for the collection mint using the
generateSigner
function and the Umi instance. - Calls the
createNft
function with the Umi instance and an object containing the necessary parameters for creating the NFT. These parameters include the collection mint, name, URI for the metadata, seller fee basis points (royalty percentage), and a flag indicating that this NFT is a collection NFT. - Sends and confirms the transaction using the Umi instance.
By executing this code, a collection NFT with the specified parameters will be created on the Solana blockchain.
Explanation of sub-aspects:
-
generateSigner(umi)
: This function generates a signer for the collection mint using the Umi instance. The signer is used to sign transactions related to the collection mint. -
createNft(umi, {...})
: This function is responsible for creating the NFT. It takes the Umi instance and an object containing the necessary parameters as arguments. The parameters include the collection mint, name, URI for the metadata, seller fee basis points (royalty percentage), and a flag indicating that this NFT is a collection NFT. -
sendAndConfirm(umi)
: This method is called on the result of thecreateNft
function to send and confirm the transaction. It takes the Umi instance as an argument and ensures that the transaction is successfully processed on the Solana blockchain. -
mplTokenMetadata()
: This function is used to enable the mpl-token-metadata program in the Umi instance. The mpl-token-metadata program is responsible for handling metadata related to NFTs, such as name, description, and image URI. -
createUmi("https://api.mainnet-beta.solana.com", "processed")
: This function creates an instance of Umi, which is a library for interacting with the Solana blockchain. It takes the Solana API endpoint and the processing mode as arguments. The processing mode determines how transactions are processed, and "processed" indicates that transactions should be processed immediately.
Ask

Soon™