npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mbkjs/nft-minter

v2.0.21

Published

This package contains `nft-minter` program bindings. Use this to connect with `nft-minter` program. The program `nft-minter` can be used for minting nfts.

Downloads

27

Readme

NFT MINTER SDK

This package contains nft-minter program bindings. Use this to connect with nft-minter program. The program nft-minter can be used for minting nfts.

Why use NFT-minter SDK ?

You can mint two categories of NFTs with nft-minter SDK.

  1. Mint Unsigned NFTs
  2. Mint Signed NFTs

Let us look at these in greater details below.

Mint Unsigned NFTs

Anyone can mint NFTs using the SDK. The restriction is that only one NFT can be minted per wallet

In this category, you can mint

  • Mint Unsigned Regular NFT - Use the SDK API to mint a normal NFT on Solana Blockchain
  • Mint Unsigned Collection NFT - Use this method from SDK to mint a collection NFT on Solana Blockcahin.

We will discuss more on how to use the APIs in greater detail below.

Mint Signed NFTs

Only users with right authorised signature from admins who deployed the nft-minter program to onchain can use methods described below.

In this category , you can mint

  • Mint Signed Regular NFT - Mint an authorised regular NFT
  • Mint Signed Collection NFT - Mint an authorised Collection NFT.

In the below section we will see examples of how to use the various APIs of nft-minter program using the @mbkjs/nft-minter SDK.

Connection and Wallet

For interacting with any program in Solana blockchain, first we need a wallet and connection to the blockchain. Here is the sample code for establishing connection with Metablocks and solana network

First import the dependencies

import { getNftMinterProgram } from '../src/factory';
import * as anchor from '@project-serum/anchor';

Then create the connection and program as below.

const connection = new anchor.web3.Connection(CLUSTER_URL, 'confirmed');
const program = getNftMinterProgram(connection, wallet);

Mint Unsigned NFTs

Minting an NFT using unsigned NFT is straight forward.

First add the dependencies

import { api } from '../src';
import { MintUnsignedNftApiArgs } from '../src/types/types';
import { getNftMinterProgram } from '../src/factory';

Then call the api as shown below

const args: MintUnsignedNftApiArgs = {
    connection: connection, // connection that we have established in the above example snippet
    wallet: claimantWallet, // wallet of the claimant
    mintName: 'Test Mint', // This could be any mint name 
    mintSymbol: 'TEST', // this could be any mint symbol
    isMasterEdition: true, // This can be true or false, It is recommended to create a masterEdition if you are creating a NFT
    isParentForNfts: false, // Keep this false if you do not want this NFT to be a parent NFT collection mint for other NFTs
    mintUri: 'http://mint.uri.com', // this can be any valid uri pointing towards a valid JSON metadata
};

const tx = await api.mintUnsignedNft(args);

Mint Unsinged Collection NFT

If you want to create a collection NFT, then you should pass a nft collection mint address . This can be mint address is normal mint address which has a metadata attached to it

In the below example we will first create a nft Collection Mint and then create a collection NFT.

Import the depenencies first

import { api, pda } from '../src';
import { MintUnsignedCollectionNftApiArgs, MintUnsignedNftApiArgs} from '../src/types/types'; 

Make a note of the mintAddress . So we will find a mintAddress as below.

const [mintAddress, _2] = await pda.findMintAddress(
    authorityWallet.publicKey
);

Then we will create a parent NFT collection

const args1: MintUnsignedNftApiArgs = {
    connection: connection, 
    wallet: authorityWallet, // we need to pass the wallet of claimant, here we have passed `authorityWallet`
    mintName: 'Test Mint',
    mintSymbol: 'TEST',
    isMasterEdition: true,
    isParentForNfts: true, // Here make this to true so this NFT will be a parent mint for the one we want to create below
    mintUri: 'http://mint.uri.com',
};

const tx1 = await api.mintUnsignedNft(args1);

Afterwards, we will create a collection NFT.

const args2: MintUnsignedCollectionNftApiArgs = {
    connection: connection,
    wallet: claimantWallet,
    mintName: 'Test Mint',
    mintSymbol: 'TEST',
    isMasterEdition: true,
    isParentForNfts: false,
    mintUri: 'http://child.mint.uri.com',
    collectionMintAddress: mintAddress, // here we passing the mintAddress of the NFT that we created above
};

const tx2 = await api.mintUnsignedCollectionNft(args2);

Mint Signed NFT

To create a signed NFT, we need a valid signature first from the authority of the one who deployed the nft-minter program.

First let us import dependencies

import { getNftMinterProgram } from '../src/factory';
import { api } from '../src';
import { MintSignedNftApiArgs } from '../src/types/types';
import nacl from 'tweetnacl';

Then we will create a dummy signature for authorising a claimant wallet address

const testMessage = claimantWallet.publicKey.toBytes();
const signature = nacl.sign.detached(testMessage, authority.secretKey); // we are passing the claimant's public address and authority secret key to create a signature

We create the signed NFT with the following API

const args: MintSignedNftApiArgs = {
    authorityAddress: authorityWallet.publicKey, // we also need to pass the authority wallet public key
    signature: signature, // signature that we created above
    message: testMessage, // message that we created above
    connection: connection,
    wallet: claimantWallet,
    mintName: 'Test Mint',
    mintSymbol: 'TEST',
    isMasterEdition: true,
    isParentForNfts: false,
    mintUri: 'http://mint.uri.com',
};

const tx = await api.mintSignedNft(args);

Mint Signed Collection NFT

It is similar to mint unsigned collection nft as we described above, only difference is that we have to pass a valid signature and message to the api

First import the dependencies

import { api, pda } from '../src';
import { MintSignedCollectionNftApiArgs, MintUnsignedNftApiArgs } from '../src/types/types';
import nacl from 'tweetnacl';

Let us mint a parent nft so that we can make this a parent nft for collection nft

const [mintAddress, _2] = await pda.findMintAddress(
    authorityWallet.publicKey
);

Then we create a unsigned regular nft as an example

const args1: MintUnsignedNftApiArgs = {
    connection: connection,
    wallet: authorityWallet,
    mintName: 'Test Mint',
    mintSymbol: 'TEST',
    isMasterEdition: true,
    isParentForNfts: true, // is this nft mint a parent mint for other mints ?
    mintUri: 'http://mint.uri.com',
};

const tx1 = await api.mintUnsignedNft(args1);

Let us create a mock signature and message for creating a singed collection NFT

const testMessage = claimantWallet.publicKey.toBytes();
const signature = nacl.sign.detached(testMessage, authority.secretKey);

Then we call the below api to create a signed collection nft

const args2: MintSignedCollectionNftApiArgs = {
    authorityAddress: authorityWallet.publicKey, // we need to pass the authority wallet public key
    connection: connection,
    wallet: claimantWallet,
    signature: signature,
    message: testMessage,
    mintName: 'Test Mint',
    mintSymbol: 'TEST',
    isMasterEdition: true,
    isParentForNfts: false,
    mintUri: 'http://child.mint.uri.com',
    collectionMintAddress: mintAddress,
};

const tx2 = await api.mintSignedCollectionNft(args2);

These are the 4 ways in which you can create NFTs.