Create a NFT
The following sample will show you how to create a NFT on Hedera Hashgraph. We will first generate a request for the end user. Once validated, you will get notified for the NFT's creation success.
Prerequisites:
Getting startedStep 1: Import the following modules
Let's continue building on the index.js from the previous example (Environment Set-up) and add the following modules:
const { Client, CategoryNFT } = require("@xact-wallet-sdk/client");
require("dotenv").config();Step 2: Get Xact Fees
In order to get the fees from our service, you need to proceed as below :
const xactFees = await client.getXactFeesCreateNFT();Step 3: Initializing Create NFT
When initializing a NFT's creation, a request will be sent to the end user
/* Update the fields with your informations */
const name = 'NFT Test';
const description = 'Description of my NFT';
const category = CategoryNFT.ART;
const creator = 'Johny.B';
const cid = ''; /* cid linked to the NFT - IPFS storage */
const supply = 1; /* Nb of NFT available */
const fromAccountId= ''; /* Account ID of the user */
const customRoyaltyFee = {
numerator: 1,
denominator: 10,
fallbackFee: 100, /* in Hbar */
};/* Optional*/
await client.createNFT({fromAccountId, name, description, category, creator, cid, supply, customRoyaltyFee});Step 4: Listen for the NFT's creation
Finally get notified when your NFT has been successfully created !
Code Check ✅
Your index.js file should look like this:
Last updated