🔨Create Non-Fungible Token

Used to create a new non-fungible token.

Planning a three step process for command line minting scripts:

  1. token create (set royalties / name / supply etc.) -> returns supply key / token ID

  2. pin images and resulting metadata on IPFS

  3. mint the NFTs using the pinned metadata

Step 1: Create the Token ID on Hedera

Start of a set of minting tools. This is 'step 1' of creating the token ID with 0 serials but ready to mint.

The script will read in the information and present you with a summary asking for confirmation to attempt the token create. once complete the script will ask if you wish to have the details & keys saved to file (highly recommended) - if not / on failure it will print to console.

Usage

Edit your .env file (rename .env.example to .env) with the following items:

#mint NFT Token 
MY_ACCOUNT_ID=0.12312
MY_PRIVATE_KEY=302e......
NFT_NAME="Super NFT"
NFT_SYMBOL=SUPER
NFT_DESC="My Super NFT on Hedera"
NFT_MAX_SUPPLY=10

Per the usage pattern you can override NFT details on the command line if needed otherwise it will use values from the .env

We recommend to remove the private key from the .env file after use. Extra precaution.

Then, in your Node.js command prompt terminal, you can use

node createNFT.js [-wipe] [-admin] [-freeze] [-save] [-royalty <XXX.json>] [-name AAA] [-symbol WWW] [-desc 'short max 100 char description here'] [-max M] [-feecap Q]

Arguments

-wipe - optional - to add a wipe key

-royalty - optional - to add royalties to the token, pass in the royalty .json file with -royalty (optional) -> see royalties_example.json for an example. Format of the json file expected:

{
	"1": {
	  "account": "0.0.123",
	  "percentage": 4
	},
	"2": {
	  "account": "0.0.456",
	  "percentage": 4
	}
}

-freeze - optional - add a freeze key

-admin - optional - add a pause key

-save - optional - save supply key and NFT info into a file

-name - optional - name of the NFT

-symbol - optional - symbol of the NFT

-desc '' - optional - max 100 characters description

-max - optional - max supply of the NFT

-feecap - optional - to cap the total of fees to spend on this operation

Step 2: Pin Metadata to IPFS

First, be sure to have your NFT.storage API KEY. See this documentation to know how to get one:

You can also use NFTUp software to pin your metadata and files to IPFS.

Step 3: Mint Supply from the Pinned Metadata

NFT minting script if you have already pinned the metatdata.json file into IPFS (see step 2) and created the token (see step 1).

Designed to track status and be replayable in case of failure during the minting process.

Usage

Edit your .env file (rename .env.example to .env) with the following items:

#mint NFT Token 
MY_ACCOUNT_ID=0.12312
MY_PRIVATE_KEY=302e......
NFT_TOKEN_ID=0.0.4655544
NFT_SUPPLY_KEY=302e......
#batch size defaults to 10 which is the maximum if missing / no value 
NFT_MINT_BATCH_SIZE=

We recommend to remove the private key from the .env file after use. Extra precaution.

Then, in your Node.js command prompt terminal, you can use

node mintNFTfromPinnedMetadata.js -process file.json

Arguments

-process json file to read in and process

File formatting for this json:

[ 
    "ipfs://XXXX/metadata.json", 
    "ipfs://YYYY/metadata.json", 
    "ipfs://ZZZZ/metadata.json"
]

or (output format of this script that includes tracking)

{
            "0: {
                    "cid": "ipfs://XXXX/metadata.json",
                    "minted": true,
                    "serial": "629"
            },
            "1": {
                    "cid": "ipfs://YYY/metadata.json",
                    "minted": false,
            },
            "2": {
                    "cid": "ipfs://ZZZZ/metadata.json",
            }
    }

Last updated