Class ConfiscateNftExtensions
Extension methods for confiscating and destroying NFT instances from an account.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class ConfiscateNftExtensions
Methods
| Edit this page View SourceConfiscateNftAsync(ConsensusClient, Nft, EntityId, Action<IConsensusContext>?)
Removes given NFT from the holding account and destroys it. Must be signed by the confiscate/wipe admin key.
Declaration
public static Task<TokenReceipt> ConfiscateNftAsync(this ConsensusClient client, Nft nft, EntityId account, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the confiscation. |
| Nft | nft | The identifier of the NFT to confiscate and destroy. |
| EntityId | account | The account holding the NFT to confiscate and destroy. |
| 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<TokenReceipt> | A transaction receipt indicating a successful operation. |
Examples
// Forcibly remove one NFT from an arbitrary holder's wallet and
// return it to the token's treasury. Requires the NFT collection's
// ConfiscateEndorsement (wipe key). Method name is singular for the
// single-NFT overload.
var receipt = await client.ConfiscateNftAsync(nft, account);
Console.WriteLine($"Confiscate 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, for example if the nft 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 confiscate request as invalid or had missing data. |
ConfiscateNftsAsync(ConsensusClient, ConfiscateNftParams, Action<IConsensusContext>?)
Confiscates and destroys multiple NFT instances.
Declaration
public static Task<TokenReceipt> ConfiscateNftsAsync(this ConsensusClient client, ConfiscateNftParams confiscateParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the confiscation. |
| ConfiscateNftParams | confiscateParams | The Parameters for confiscating the NFTs, including the list of NFTs to confiscate and destroy. |
| 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<TokenReceipt> | A token transaction receipt indicating a successful operation. |
Examples
// Confiscate several NFTs from the same collection and holder in one
// transaction. Method name becomes plural (ConfiscateNftsAsync) for
// the params-object form.
var receipt = await client.ConfiscateNftsAsync(new ConfiscateNftParams
{
Token = collection,
Account = account,
SerialNumbers = new long[] { 1, 2, 3 }
});
Console.WriteLine($"Confiscate 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, for example if the nft 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 confiscate request as invalid or had missing data. |