DAN
Website
  • 🚀Accelerating Digital Ownership Adoption
  • Digital Assets Network
    • ❌Challenges in Adoption
    • ✅DAN Stack
    • 📜Modular Protocol
    • 🎯DAN Labs Impact
    • 🔐®️ ERC-7066 Author
      • Overview
  • DAN PROTOCOLS
    • 📌Modular Solutions for Digital Ownership
    • 💡Asset Creation
    • 🤝Marketplace
    • 🔓Rent Protocol
    • 💰Loan Protocol
      • How does a loan work?
    • 💰Utility Protocol
      • How does it work?
  • For Developers
    • 🚀Launchpad
      • APIs
        • User's Collections
        • Collection Details
      • SDK
        • Create Collection
        • Mint NFT
        • Mint NFT (Batch)
    • 🛒Market
      • APIs
      • SDK
        • Create Listing
        • Buy Listed NFT
        • Cancel Listing
    • ⚙️Utility
      • APIs
        • 👥Client
          • Register
          • Verify
          • Redeem Code
          • Get All Claimed Utility User
        • 👨‍💻Developer
          • Get All Benefits By Collection
      • SDK
    • 💰Loans
      • APIs
        • User Loans
        • Raw Transactions (Advanced)
      • SDK
        • EVM
        • Solana
      • Wallet Integration
        • EVM
        • Solana
    • 🗞️Rentals
      • APIs
        • NFTs (Owned and Rented)
        • NFTs (Rented)
        • Raw Transactions (Advanced)
      • On-Chain
      • SDK
        • EVM
        • Solana
      • Wallet Integration
        • EVM
        • Solana
    • ⛓️Supported Chains
  • UseCases : Case Studies
    • 🤝NFT Rentals
    • 💎Ephemeral / Consumable NFTs
    • 📝NFT Mandates
    • 🎆Post-Mint Utility
    • 💼Partial Payment at Mint
  • Community
    • 🔑Terms of Service
    • 🔏Privacy Policy
    • 🌐Website
    • 👽Discord
    • 🐦Twitter
Powered by GitBook
On this page
  1. For Developers
  2. Launchpad
  3. SDK

Mint NFT

Mint Single NFT

The mintNFT function, imported from streamnft-evm, facilitates minting various types of tokens (ERC721, ERC1155, Certificate) on the Ethereum Virtual Machine (EVM). It supports both public and private minting methods for different token standards.


🔧 Function Signature

await mintNFT(
  tokenType,
  price,  // Price in Wei
  amount,  // Amount (irrelevant for ERC721)
  signature,  // Signature
  tokenUri,  // Token URI
  tokenId,  // Token ID
  chainId,  // Chain ID
  signer,
  contractAddress
);

📄 Parameters
  • tokenType (number, required): The type of token to be minted, specified in the TokenType enumeration.

  • price (BigInt | number, optional): The price per token in Wei for public minting. For private tokens, this is not required.

  • amount (number, optional): The quantity of tokens to mint (mainly for ERC1155).

  • signature (string, optional): A pre-approved signature required for ERC721Public minting.

  • tokenUri (string, optional): The metadata URI for the NFT.

  • tokenId (number, optional): The ID of the token to mint.

  • chainId (number, required): The chain ID where the contract is deployed.

  • signer (Signer, required): The wallet or account object initiating the transaction.

  • contractAddress (string, required): The address of the deployed NFT contract.


✅ Example Usage

1. ERC721Public (Public Minting)

  • Required: price, signature, tokenUri, tokenId

  • Example:


await mintNFT(
  TokenType.ERC721Public,
  ethers.utils.parseEther("0.05"),  // Price in Wei
  1,  // Amount (irrelevant for ERC721)
  "0xValidSignature",  // Signature
  "<https://example.com/metadata/1>",  // Token URI
  1,  // Token ID
  80001,  // Chain ID (Polygon Mumbai Testnet)
  signer,
  "0xContractAddress"
);

2. ERC721Private (Private Minting)

  • Required: tokenUri

  • Example:

await mintNFT(
  TokenType.ERC721Private,
  0,  // Price not required
  1,
  "",
  "<https://example.com/metadata/2>",
  2,
  80001,
  signer,
  "0xContractAddress"
);

3. ERC1155Public (Public Minting)

  • Required: price, amount, tokenId

  • Example:


await mintNFT(
  TokenType.ERC1155Public,
  ethers.utils.parseEther("0.02"),
  10,  // Amount to mint
  "",
  "<https://example.com/metadata/3>",
  3,  // Token ID
  80001,
  signer,
  "0xContractAddress"
);

4. ERC1155Private (Private Minting)

  • Required: amount, tokenId

  • Example:

await mintNFT(
  TokenType.ERC1155Private,
  0,
  5,  // Amount to mint
  "",
  "<https://example.com/metadata/4>",
  4,
  80001,
  signer,
  "0xContractAddress"
);

5. Certificate (Owner-Only Minting)

  • No price, amount, or tokenUri required.

  • Example:

await mintNFT(
  TokenType.Certificate,
  0,
  1,
  "",
  "",
  0,
  80001,
  signer,
  "0xContractAddress"
);

Return Value

An object containing:

  • success (boolean): Indicates if minting was successful.

  • tokenType (number): The type of token minted.

  • transactionHash (string): The hash of the transaction.

  • error (string): Error message, if applicable.


Error Handling

  • Throws Invalid token type if tokenType does not match a supported type.

  • Throws Unsupported token type for SoulBound and ERC7066 tokens (not yet implemented).

  • Catches and logs errors if the transaction fails.

PreviousCreate CollectionNextMint NFT (Batch)

Last updated 2 months ago

🚀