NFT
The NFT class oversees NFTs generated from a holographable contract, offering functionality for minting NFTs.
1. Constructor Parameters
createNFTInput
- Type:CreateNFTrequired
The input object to enable the NFT settings and mints.
type CreateNFT = {
collection:
| HolographLegacyCollection // NFT class usage
| HolographMoeERC721DropV2; // MoeNFT class usage
metadata: {
name: string;
description: string;
creator: string;
attributes?: Record<string, string>;
};
ipfsInfo: {
ipfsImageCid: string;
ipfsMetadataCid: string;
ipfsUrl?: string;
};
version?: HolographVersion;
};
enum HolographVersion {
V1 = "V1",
V2 = "V2",
}
src/holograph/nft.ts
import { HolographLegacyCollection, NFT } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";
import { holographConfig } from "./config";
const myContract = new HolographLegacyCollection(holographConfig, {
primaryChainId: networks.polygon.chain,
collectionInfo: {
name: "My First Collection",
symbol: "MFC",
description: "Probably nothing.",
royaltiesBps: 2000, // 20%
salt: "0x0000000000000000000000000000000000000000000000000000018e7cc167e2",
},
});
const myNFT = new NFT({
collection: myContract,
metadata: {
name: "My new NFT",
description: "Probably nothing.",
creator: "Holograph Protocol",
},
ipfsInfo: {
ipfsImageCid: "QmfPiMDcWQNPmJpZ1MKicVQzoo42Jgb2fYFH7PemhXkM32",
ipfsMetadataCid:
"QmfPiMDcWQNPmJpZ1MKicVQzoo42Jgb2fYFH7PemhXkM32/metadata.json",
},
});
- Validation:
- collection: HolographLegacyCollection | HolographMoeERC721DropV2required- must be a valid instance of the contract class.
HolographLegacyCollection
is utilized in conjunction with theNFT
class, whereasHolographMoeERC721DropV2
is utilized with theMoeNFT
class. - metadata:
- name: stringrequired
- description: stringrequired
- creator: stringrequired
- attributes: Record<string, string>
- name:
- ipfsInfo:
- ipfsImageCid: stringrequired
- ipfsMetadataCid: stringrequired
- ipfsUrl: stringdefault: ""
- ipfsImageCid:
- version: HolographVersiondefault: V2
- collection:
-
Setters:
NFT
class has a couple of setters and they need to follow the above validation. Here's the full list:- setName()
- setDescription()
- setCreator()
- setAttributes()
- setIpfsImageCid()
- setIpfsMetadataCid()
- setIpfsUrl()