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