Class ScheduleExtensions
Extension methods for creating scheduled transactions on the network.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class ScheduleExtensions
Methods
| Edit this page View SourceScheduleAsync(ConsensusClient, ScheduleParams, Action<IConsensusContext>?)
Creates a new scheduled transaction on the network. The inner transaction will be held by the network and executed when all required signatures are collected.
Declaration
public static Task<ScheduleReceipt> ScheduleAsync(this ConsensusClient client, ScheduleParams scheduleParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the request. |
| ScheduleParams | scheduleParams | The details of the scheduled transaction to create. |
| 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<ScheduleReceipt> | A receipt containing the schedule ID and the scheduled transaction ID that will be used when executed. |
Examples
Full ScheduleParams overload — use when you need an administrator key, expiration time, payer override, or delayed execution:
var receipt = await client.ScheduleAsync(new ScheduleParams
{
Transaction = new TransferParams
{
CryptoTransfers = new[]
{
new CryptoTransfer(sender, -amount),
new CryptoTransfer(recipient, amount)
}
},
Memo = "Scheduled transfer from Hiero SDK sample",
Expiration = new ConsensusTimeStamp(DateTime.UtcNow.AddHours(1))
});
Console.WriteLine($"Schedule created: {receipt.Schedule}");
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 create request as invalid or had missing data. |
ScheduleAsync(ConsensusClient, TransactionParams, Action<IConsensusContext>?)
Creates a new scheduled transaction on the network. The inner transaction will be held by the network and executed when all required signatures are collected.
Declaration
public static Task<ScheduleReceipt> ScheduleAsync(this ConsensusClient client, TransactionParams transactionParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the request. |
| TransactionParams | transactionParams | The transaction to schedule for future execution. This can be any supported transaction type that implements the schedulable transaction interface. |
| 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<ScheduleReceipt> | A receipt containing the schedule ID and the scheduled transaction ID that will be used when executed. |
Examples
Convenience overload: schedule a transaction directly without wrapping it in ScheduleParams:
// Convenience overload: schedule any transaction directly without
// wrapping it in ScheduleParams. Use the full ScheduleParams overload
// if you need an Administrator key, Payer override, Expiration, or
// DelayExecution.
var receipt = await client.ScheduleAsync(new TransferParams
{
CryptoTransfers = new[]
{
new CryptoTransfer(sender, -amount),
new CryptoTransfer(recipient, amount)
}
});
Console.WriteLine($"Schedule id: {receipt.Schedule}");
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 create request as invalid or had missing data. |
SubmitAsync(ConsensusClient, ScheduleParams, Action<IConsensusContext>?)
Creates, signs, submits a scheduling transaction and waits for a response from the target consensus node. Returning the precheck response code. A PrecheckException may be thrown under certain invalid input scenarios.
Declaration
public static Task<ResponseCode> SubmitAsync(this ConsensusClient client, ScheduleParams scheduleParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the request. |
| ScheduleParams | scheduleParams | Scheduling transaction input parameters. |
| Action<IConsensusContext> | configure | Optional callback to configure the calling context immediately before assembling the transaction for submission. |
Returns
| Type | Description |
|---|---|
| Task<ResponseCode> | The precheck ResponseCode returned from the request after waiting for submission retries if applicable. |
Remarks
This method will wait for the target consensus node to respond with a code other than Busy or InvalidTransactionStart if applicable, until such time as the retry count is exhausted, in which case it is possible to receive a Busy response.