Minting is the process of creating new NFT tokens within your collection. CreateKit provides a unique two-phase minting system that optimizes for gas efficiency and user experience.
CreateKit supports both ERC721 and ERC1155 standards with different minting behaviors:
ERC721 Unique Tokens
Copy
Ask AI
// ERC721 - Each token is uniqueconst erc721Collection = collectionManager.createCollection( predictedAddress, "ERC721")// ERC721 always mints quantity of 1await erc721Collection.mint( walletClient, 1n, // Always 1 for ERC721 "https://example.com/metadata/1.json", // Unique metadata for this token parseEther("0.01"), [])// Each mint creates a new unique token ID// Token IDs increment: 1, 2, 3, etc.
// Get proof for the minting addressconst userAddress = account.addressconst proof = whitelist.getProof(userAddress)// Verify user is in whitelist (optional check)const isWhitelisted = whitelist.verify(userAddress, proof)if (!isWhitelisted) { throw new Error("Address not in whitelist")}// Mint with whitelist proofawait collection.mint( walletClient, 1n, undefined, parseEther("0.005"), proof // Provide whitelist proof)
CreateKit can automatically generate metadata based on collection settings:
Auto-Generated Metadata
Copy
Ask AI
// Using baseURI for automatic metadataconst autoMetadataCollection = { name: "Auto Metadata Collection", symbol: "AMC", creator: account.address, gameOwner: account.address, // baseURI will be generated automatically by BaseMint CDN}// Mint with automatic metadata (pass undefined for URI)await collection.mint( walletClient, 1n, undefined, // Uses baseURI + tokenId 0n, [])// Metadata will be available at: {baseURI}/{tokenId}
// Provide specific metadata URI for each tokenconst customMetadataURIs = [ "https://myapi.com/metadata/special-sword.json", "https://myapi.com/metadata/rare-shield.json", "https://myapi.com/metadata/epic-helmet.json"]for (const metadataURI of customMetadataURIs) { await collection.mint( walletClient, 1n, metadataURI, // Custom metadata for this token parseEther("0.01"), [] )}
For ERC1155 collections, you can efficiently mint multiple tokens:
Batch Minting
Copy
Ask AI
// Single transaction, multiple tokensawait erc1155Collection.mint( walletClient, 10n, // Mint 10 tokens of the same type "https://example.com/metadata/resource.json", parseEther("0.001") * 10n, // Total price for all tokens [])// For different token types, use separate transactionsconst tokenTypes = [ { uri: "https://example.com/wood.json", quantity: 5n }, { uri: "https://example.com/stone.json", quantity: 3n }, { uri: "https://example.com/gold.json", quantity: 1n }]for (const tokenType of tokenTypes) { await erc1155Collection.mint( walletClient, tokenType.quantity, tokenType.uri, calculatePrice(tokenType.quantity), [] )}
// For ERC1155: Mint multiple tokens in one transactionawait erc1155Collection.mint( walletClient, 10n, // More gas-efficient than 10 separate transactions metadataURI, totalPrice, proof)// For ERC721: Consider batch operations at the application levelconst mintPromises = []for (let i = 0; i < 5; i++) { mintPromises.push( collection.mint(walletClient, 1n, undefined, mintPrice, proof) )}// Execute mints concurrently (be careful with nonce management)const results = await Promise.all(mintPromises)