Class RelinquishTokenExtensions
Extension methods for relinquishing tokens and NFTs back to the treasury.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class RelinquishTokenExtensions
Methods
| Edit this page View SourceRelinquishAsync(ConsensusClient, RelinquishTokensParams, Action<IConsensusContext>?)
Relinquishes one or more tokens and/or NFTs using detailed parameters.
Declaration
public static Task<TransactionReceipt> RelinquishAsync(this ConsensusClient client, RelinquishTokensParams relinquishParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the relinquishment. |
| RelinquishTokensParams | relinquishParams | The rejection parameters, including optional owner, fungible tokens, and NFTs to reject. |
| 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
// Surrender several tokens and NFTs in a single transaction. Any
// mix of Tokens[] and Nfts[] is allowed.
var receipt = await client.RelinquishAsync(new RelinquishTokensParams
{
Tokens = new[] { token1, token2 },
Nfts = new[] { nft1 }
});
Console.WriteLine($"Relinquish 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. |
RelinquishNftAsync(ConsensusClient, Nft, Action<IConsensusContext>?)
Relinquishes a specific NFT instance, returning it to the token treasury.
Declaration
public static Task<TransactionReceipt> RelinquishNftAsync(this ConsensusClient client, Nft nft, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the relinquishment. |
| Nft | nft | The NFT instance to reject. |
| 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
// Surrender a specific NFT back to the treasury. Useful for
// unwanted airdropped NFTs once they have already been claimed.
var receipt = await client.RelinquishNftAsync(nft);
Console.WriteLine($"Relinquish 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. |
RelinquishTokenAsync(ConsensusClient, EntityId, Action<IConsensusContext>?)
Relinquishes a fungible token, returning the full balance to the token treasury.
Declaration
public static Task<TransactionReceipt> RelinquishTokenAsync(this ConsensusClient client, EntityId token, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the relinquishment. |
| EntityId | token | The fungible token type to relinquish. |
| 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
// A holder returns (dissociates) a fungible token they no longer want.
// Unlike DissociateTokenAsync (which requires zero balance), this
// actively surrenders any held tokens back to the treasury.
var receipt = await client.RelinquishTokenAsync(token);
Console.WriteLine($"Relinquish 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. |