Class TransactionBatchParamsExtensions
Extension methods for submitting batched transactions to the network.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class TransactionBatchParamsExtensions
Methods
| Edit this page View SourceExecuteAsync(ConsensusClient, BatchedTransactionParams, Action<IConsensusContext>?)
Creates, signs, submits a batch of transactions and waits for a response from the target consensus node, returning a receipt.
Declaration
public static Task<TransactionReceipt> ExecuteAsync(this ConsensusClient client, BatchedTransactionParams batchParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the batch submission. |
| BatchedTransactionParams | batchParams | The details of the batched transactions to create, sign and submit. |
| Action<IConsensusContext> | configure | Optional callback to configure the calling context immediately before assembling the transaction for submission. |
Returns
| Type | Description |
|---|---|
| Task<TransactionReceipt> | A receipt object. |
Examples
// Atomic batch: every inner transaction either all succeeds or all
// fails. Pass any combination of TransactionParams subclasses. The
// batch is signed by every inner transaction's signatory plus the
// batch-level Signatory if set.
var receipt = await client.ExecuteAsync(new BatchedTransactionParams
{
TransactionParams = new TransactionParams[]
{
new TransferParams
{
CryptoTransfers = new[]
{
new CryptoTransfer(sender1, -100_000_000),
new CryptoTransfer(receiver, 100_000_000)
}
},
new TransferParams
{
CryptoTransfers = new[]
{
new CryptoTransfer(sender2, -50_000_000),
new CryptoTransfer(receiver, 50_000_000)
}
}
}
});
Console.WriteLine($"Batch status: {receipt.Status}");
Exceptions
| Type | Condition |
|---|---|
| PrecheckException | If there was a problem submitting the request, including the consensus node considering the request invalid. |
| TransactionException | If the consensus node returned a failure code and throw on failure is set to
in the client context configuration. |
| ConsensusException | Under heavy load, the network may not process the transaction before it expires. |
SubmitAsync(ConsensusClient, BatchedTransactionParams, Action<IConsensusContext>?)
Creates, signs, submits a batch of transactions 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, BatchedTransactionParams batchParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the batch submission. |
| BatchedTransactionParams | batchParams | The batched 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.
Examples
Precheck-only submission — returns as soon as the gateway responds:
// Send the batch and return as soon as the gateway precheck responds,
// without waiting for consensus. Useful for fire-and-forget workloads
// that recover via mirror-node polling for the final receipt.
var precheckCode = await client.SubmitAsync(new BatchedTransactionParams
{
TransactionParams = new TransactionParams[]
{
new TransferParams
{
CryptoTransfers = new[]
{
new CryptoTransfer(sender, -1_000_000),
new CryptoTransfer(receiver, 1_000_000)
}
}
}
});
Console.WriteLine($"Precheck code: {precheckCode}");