> For the complete documentation index, see [llms.txt](https://danlabs.gitbook.io/dan/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://danlabs.gitbook.io/dan/for-developers/launchpad/sdk/mint-nft.md).

# 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

```jsx
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
);
```

***

<details>

<summary>📄 Parameters</summary>

* `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.

</details>

***

<details>

<summary>✅ Example Usage</summary>

**1. ERC721Public (Public Minting)**

* Required: `price`, `signature`, `tokenUri`, `tokenId`
* Example:

<pre class="language-jsx"><code class="lang-jsx">
<strong>await mintNFT(
</strong>  TokenType.ERC721Public,
  ethers.utils.parseEther("0.05"),  // Price in Wei
  1,  // Amount (irrelevant for ERC721)
  "0xValidSignature",  // Signature
  "&#x3C;https://example.com/metadata/1>",  // Token URI
  1,  // Token ID
  80001,  // Chain ID (Polygon Mumbai Testnet)
  signer,
  "0xContractAddress"
);

</code></pre>

**2. ERC721Private (Private Minting)**

* Required: `tokenUri`
* Example:

```jsx
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:

```jsx

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:

```jsx
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:

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

```

</details>

***

#### 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://danlabs.gitbook.io/dan/for-developers/launchpad/sdk/mint-nft.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
