Class MintNftExtensions
Extension methods for minting new NFT instances on the network.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class MintNftExtensions
Methods
| Edit this page View SourceMintNftAsync(ConsensusClient, EntityId, ReadOnlyMemory<byte>, Action<IConsensusContext>?)
Creates (Mints) a new Non-Fungible Token (NFTs) under the specified token definition.
Declaration
public static Task<NftMintReceipt> MintNftAsync(this ConsensusClient client, EntityId token, ReadOnlyMemory<byte> metadata, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the mint. |
| EntityId | token | The identifier of the token type of NFTs to mint. |
| ReadOnlyMemory<byte> | metadata | The Metadata associated with the newly created NFT. |
| Action<IConsensusContext> | configure | Optional callback method providing an opportunity to modify the execution configuration for just this method call. It is executed prior to submitting the request to the network. |
Returns
| Type | Description |
|---|---|
| Task<NftMintReceipt> | A mint transaction receipt indicating a successful operation. |
Examples
// Mint a single NFT with UTF-8-encoded JSON metadata (CID-style strings
// are the typical choice — the network does not interpret the bytes).
// The supply key must sign. The receipt's SerialNumbers array holds
// the newly issued serial number.
var metadata = Encoding.UTF8.GetBytes("{\"name\":\"Artifact #1\"}");
var receipt = await client.MintNftAsync(nftCollection, metadata);
Console.WriteLine($"Minted serial: {receipt.SerialNumbers[0]}");
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If required arguments are missing. |
| InvalidOperationException | If required context configuration is missing. |
| PrecheckException | If the gateway node rejected the request upon submission, for example, if the token is already deleted. |
| ConsensusException | If the network was unable to come to consensus before the duration of the transaction expired. |
| TransactionException | If the network rejected the create request as invalid or had missing data. |
MintNftsAsync(ConsensusClient, MintNftParams, Action<IConsensusContext>?)
Creates (Mints) new Non-Fungible Tokens (NFTs) under the specified token definition.
Declaration
public static Task<NftMintReceipt> MintNftsAsync(this ConsensusClient client, MintNftParams mintParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the mint. |
| MintNftParams | mintParams | The Parameters for minting the NFTs, including the metadata to be associated with each minted NFT. |
| Action<IConsensusContext> | configure | Optional callback method providing an opportunity to modify the execution configuration for just this method call. It is executed prior to submitting the request to the network. |
Returns
| Type | Description |
|---|---|
| Task<NftMintReceipt> | A mint transaction receipt indicating a successful operation. |
Examples
var mintReceipt = await client.MintNftsAsync(new MintNftParams
{
Token = createReceipt.Token,
Metadata = new[]
{
(ReadOnlyMemory<byte>)Encoding.UTF8.GetBytes("{\"name\":\"NFT #1\"}"),
(ReadOnlyMemory<byte>)Encoding.UTF8.GetBytes("{\"name\":\"NFT #2\"}"),
(ReadOnlyMemory<byte>)Encoding.UTF8.GetBytes("{\"name\":\"NFT #3\"}")
}
});
Console.WriteLine($"Minted serial numbers: {string.Join(", ", mintReceipt.SerialNumbers)}");
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If required arguments are missing. |
| InvalidOperationException | If required context configuration is missing. |
| PrecheckException | If the gateway node rejected the request upon submission, for example, if the token is already deleted. |
| ConsensusException | If the network was unable to come to consensus before the duration of the transaction expired. |
| TransactionException | If the network rejected the create request as invalid or had missing data. |