Class AirdropExtensions
Extension methods for airdropping tokens and NFTs on the network.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class AirdropExtensions
Methods
| Edit this page View SourceAirdropAsync(ConsensusClient, AirdropParams, Action<IConsensusContext>?)
Airdrops one or more tokens and/or NFTs using detailed parameters.
Declaration
public static Task<TransactionReceipt> AirdropAsync(this ConsensusClient client, AirdropParams airdropParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the airdrop. |
| AirdropParams | airdropParams | The airdrop parameters containing the token and NFT transfers. |
| 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
// Airdrop the same token to three recipients in one transaction. The
// sender debit (-300) is split into credits totaling +300 across the
// receivers. Per-token amounts in a TokenTransfers list must sum to
// zero, just like CryptoTransfer lists.
var receipt = await client.AirdropAsync(new AirdropParams
{
TokenTransfers = new[]
{
new TokenTransfer(token, sender, -300),
new TokenTransfer(token, recipient1, 100),
new TokenTransfer(token, recipient2, 100),
new TokenTransfer(token, recipient3, 100),
}
});
Console.WriteLine($"Airdrop 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. |
AirdropNftAsync(ConsensusClient, Nft, EntityId, EntityId, Action<IConsensusContext>?)
Airdrops an NFT from one account to another.
Declaration
public static Task<TransactionReceipt> AirdropNftAsync(this ConsensusClient client, Nft nft, EntityId fromAddress, EntityId toAddress, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the airdrop. |
| Nft | nft | The NFT instance to airdrop. |
| EntityId | fromAddress | The account sending the NFT. |
| EntityId | toAddress | The account receiving the 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<TransactionReceipt> | A transaction receipt indicating a successful operation. |
Remarks
If the recipient is already associated with the token or has auto-association slots available, the transfer completes immediately. Otherwise, a pending airdrop is created that the recipient must claim.
Examples
// Airdrop a single NFT. Same pending-claim semantics as fungible
// airdrops: if the recipient already holds the collection or has
// auto-association slots, it settles immediately.
var receipt = await client.AirdropNftAsync(nft, sender, recipient);
Console.WriteLine($"NFT airdrop 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. |
AirdropTokenAsync(ConsensusClient, EntityId, EntityId, EntityId, long, Action<IConsensusContext>?)
Airdrops a fungible token from one account to another.
Declaration
public static Task<TransactionReceipt> AirdropTokenAsync(this ConsensusClient client, EntityId token, EntityId fromAddress, EntityId toAddress, long amount, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the airdrop. |
| EntityId | token | The fungible token type to airdrop. |
| EntityId | fromAddress | The account sending the tokens. |
| EntityId | toAddress | The account receiving the tokens. |
| long | amount | The amount of tokens to airdrop. |
| 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. |
Remarks
If the recipient is already associated with the token or has auto-association slots available, the transfer completes immediately. Otherwise, a pending airdrop is created that the recipient must claim.
Examples
// Airdrop fungible tokens. If the recipient is already associated or
// has a free auto-association slot, the transfer settles immediately.
// Otherwise a pending airdrop is created that the recipient claims
// with ClaimAirdropAsync.
var receipt = await client.AirdropTokenAsync(token, sender, recipient, amount);
Console.WriteLine($"Airdrop 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. |