Class UpdateNftsExtensions
Extension methods for updating NFT instance metadata on the network.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class UpdateNftsExtensions
Methods
| Edit this page View SourceUpdateNftMetadataAsync(ConsensusClient, Nft, ReadOnlyMemory<byte>, Action<IConsensusContext>?)
Updates the metadata of a single NFT instance.
Declaration
public static Task<TransactionReceipt> UpdateNftMetadataAsync(this ConsensusClient client, Nft nft, ReadOnlyMemory<byte> metadata, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the update. |
| Nft | nft | The NFT instance to update. |
| ReadOnlyMemory<byte> | metadata | The new metadata to assign to the NFT instance. Must not exceed 100 bytes. |
| 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<TransactionReceipt> | A transaction receipt indicating a successful operation. |
Examples
// Replace the metadata bytes on one specific NFT. Requires the
// collection's MetadataEndorsement to sign. Common for rotating
// off-chain JSON references after the initial mint.
var newMetadata = Encoding.UTF8.GetBytes("{\"name\":\"Revised\"}");
var receipt = await client.UpdateNftMetadataAsync(nft, newMetadata);
Console.WriteLine($"Update status: {receipt.Status}");
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. |
| ConsensusException | If the network was unable to come to consensus before the duration of the transaction expired. |
| TransactionException | If the network rejected the request as invalid or had missing data. |
UpdateNftsMetadataAsync(ConsensusClient, UpdateNftsParams, Action<IConsensusContext>?)
Updates the metadata of one or more NFT instances.
Declaration
public static Task<TransactionReceipt> UpdateNftsMetadataAsync(this ConsensusClient client, UpdateNftsParams updateParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the update. |
| UpdateNftsParams | updateParams | The parameters for updating the NFTs, including the token, serial numbers, and new metadata. |
| 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<TransactionReceipt> | A transaction receipt indicating a successful operation. |
Examples
// Apply the *same* metadata blob to multiple serials at once. Use
// the params form when rotating a shared metadata reference across a
// set of NFTs in one collection. Method names: singular-one is
// `UpdateNftMetadataAsync`, plural-batch is `UpdateNftsMetadataAsync`.
var receipt = await client.UpdateNftsMetadataAsync(new UpdateNftsParams
{
Token = collection,
SerialNumbers = new long[] { 1, 2, 3 },
Metadata = Encoding.UTF8.GetBytes("{\"cid\":\"bafy...\"}")
});
Console.WriteLine($"Update status: {receipt.Status}");
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. |
| ConsensusException | If the network was unable to come to consensus before the duration of the transaction expired. |
| TransactionException | If the network rejected the request as invalid or had missing data. |