Class ConfiscateTokenExtensions
Extension methods for confiscating fungible tokens from an account.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class ConfiscateTokenExtensions
Methods
| Edit this page View SourceConfiscateTokensAsync(ConsensusClient, ConfiscateTokenParams, Action<IConsensusContext>?)
Removes the holdings of given token from the associated account and removes them from circulation. Must be signed by the confiscate/wipe admin key.
Declaration
public static Task<TokenReceipt> ConfiscateTokensAsync(this ConsensusClient client, ConfiscateTokenParams confiscateParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the confiscation. |
| ConfiscateTokenParams | confiscateParams | The details identifying the token, holder, and amount to confiscate. |
| 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 tokens from a holder's balance and send them to
// nowhere (reduces total circulation). Requires the ConfiscateEndorsement.
// Method name is plural: ConfiscateTokensAsync.
var receipt = await client.ConfiscateTokensAsync(token, holder, amount);
Console.WriteLine($"Confiscate status: {receipt.Status}");
Console.WriteLine($"Remaining circulation: {receipt.Circulation}");
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 request as invalid or had missing data. |
ConfiscateTokensAsync(ConsensusClient, EntityId, EntityId, ulong, Action<IConsensusContext>?)
Removes the holdings of given token from the associated account and removes them from circulation. Must be signed by the confiscate/wipe admin key.
Declaration
public static Task<TokenReceipt> ConfiscateTokensAsync(this ConsensusClient client, EntityId token, EntityId holder, ulong amount, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the confiscation. |
| EntityId | token | The identifier of the token that will be confiscated. |
| EntityId | holder | Holder holding the tokens to be confiscated. |
| ulong | amount | The amount of fungible token to confiscate and remove from circulation. |
| 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 tokens from a holder's balance and send them to
// nowhere (reduces total circulation). Requires the ConfiscateEndorsement.
// Method name is plural: ConfiscateTokensAsync.
var receipt = await client.ConfiscateTokensAsync(token, holder, amount);
Console.WriteLine($"Confiscate status: {receipt.Status}");
Console.WriteLine($"Remaining circulation: {receipt.Circulation}");
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 request as invalid or had missing data. |