Class ExternalTransactionParamsExtensions
Extension methods for submitting externally created transactions to the network.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class ExternalTransactionParamsExtensions
Methods
| Edit this page View SourceSendExternalTransactionAsync(ConsensusClient, ExternalTransactionParams, Action<IConsensusContext>?)
Sends an arbitrary externally created Hedera Transaction to the network,
but does not wait for a receipt, only returning the
PRECHECK
code returned from the network (as
ResponseCode
). The transaction is submitted as a
SignedTransaction
object, protobuf encoded, and may include signatures in the associated
<pre><code class="lang-csharp">sigMap</code></pre>
field. Any Signatories held in the client context
(or method call) will add signatures to this transaction prior to submitting.
It is not necessary to include a
Payer
in the context as the transaction itself defines the payer, however a matching (via Node Account ID)
<pre><code class="lang-csharp">ConsensusNodeEndpoint</code></pre>
must be contained in the client's context as it provides the necessary gRPC routing to the Hedera Network’s node, which is not encoded in the signed transaction structure.
Declaration
public static Task<ResponseCode> SendExternalTransactionAsync(this ConsensusClient client, ExternalTransactionParams externalParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client submitting the raw transaction to the network. |
| ExternalTransactionParams | externalParams |
object to be submitted to the network. |
| 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<ResponseCode> |
corresponding to the precheck value returned from the remote Hedera Gossip Node which can indicate success or failure. This method does not wait for consensus and does not return a receipt. However, it will retry sending the transaction when it receives a
response from the remote node. |
Remarks
Note: this method accepts protobuf encoded as a
SignedTransaction
, not a
Transaction
object as the transaction object contains deprecated protobuf fields not supported by this SDK. The method will perform the necessary final wrapping of the transaction for final submission.
Examples
// Use the params overload to layer additional signatures on top of
// an externally-signed transaction without re-building the body.
// Any Signatory in the client's context is also applied.
var receipt = await client.SubmitExternalTransactionAsync(new ExternalTransactionParams
{
SignedTransactionBytes = signedBytes,
Signatory = extraSignatory
});
Console.WriteLine($"Status: {receipt.Status}");
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If required arguments are missing. |
| InvalidOperationException | If required context configuration is missing. |
| PrecheckException | If transaction submission failed due to network communication errors. The PrecheckException will not be thrown for PRECHECK error codes returned from the remote gRPC endpoint. This behavior is different from most other API calls that throw a PrecheckException for any precheck value returned that is not
. The PrecheckException is thrown because there is no true response code to return and the method should divulge some information as to the nature of the network error. |
SendExternalTransactionAsync(ConsensusClient, ReadOnlyMemory<byte>, CancellationToken, Action<IConsensusContext>?)
Sends an arbitrary externally created Hedera Transaction to the network,
but does not wait for a receipt, only returning the
PRECHECK
code returned from the network (as
ResponseCode
). The transaction is submitted as a
SignedTransaction
object, protobuf encoded, and may include signatures in the associated
<pre><code class="lang-csharp">sigMap</code></pre>
field. Any Signatories held in the client context
(or method call) will add signatures to this transaction prior to submitting.
It is not necessary to include a
Payer
in the context as the transaction itself defines the payer, however a matching (via Node Account ID)
<pre><code class="lang-csharp">ConsensusNodeEndpoint</code></pre>
must be contained in the client's context as it provides the necessary gRPC routing to the Hedera Network’s node, which is not encoded in the signed transaction structure.
Declaration
public static Task<ResponseCode> SendExternalTransactionAsync(this ConsensusClient client, ReadOnlyMemory<byte> signedTransactionBytes, CancellationToken cancellationToken = default, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client submitting the raw transaction to the network. |
| ReadOnlyMemory<byte> | signedTransactionBytes |
|
| CancellationToken | cancellationToken | Optional cancellation token. |
| 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<ResponseCode> |
corresponding to the precheck value returned from the remote Hedera Gossip Node which can indicate success or failure. This method does not wait for consensus and does not return a receipt. However, it will retry sending the transaction when it receives a
response from the remote node. |
Remarks
Note: this method accepts protobuf encoded as a
SignedTransaction
, not a
Transaction
object as the transaction object contains deprecated protobuf fields not supported by this SDK. The method will perform the necessary final wrapping of the transaction for final submission.
Examples
// Forward a transaction built entirely by external tooling (e.g. a
// hardware wallet). Send returns the precheck ResponseCode without
// waiting for consensus. Use when you've already externally signed
// bytes and just need them relayed to a gossip node.
var code = await client.SendExternalTransactionAsync(preBuiltSignedTransactionBytes);
Console.WriteLine($"Precheck: {code}");
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If required arguments are missing. |
| InvalidOperationException | If required context configuration is missing. |
| PrecheckException | If transaction submission failed due to network communication errors. The PrecheckException will not be thrown for PRECHECK error codes returned from the remote gRPC endpoint. This behavior is different from most other API calls that throw a PrecheckException for any precheck value returned that is not
. The PrecheckException is thrown because there is no true response code to return and the method should divulge some information as to the nature of the network error. |
SubmitExternalTransactionAsync(ConsensusClient, ExternalTransactionParams, Action<IConsensusContext>?)
Submits an arbitrary externally created Hedera Transaction to the network.
The Transaction is submitted as a
SignedTransaction
object, protobuf encoded, and may include signatures in the associated
<pre><code class="lang-csharp">sigMap</code></pre>
field. Any Signatories held in the client context
(or method call) will add signatures to this network transaction prior to submitting.
It is not necessary to include a
Payer
in the context as the Transaction itself defines the payer, however a matching (via Node Account ID)
<pre><code class="lang-csharp">ConsensusNodeEndpoint</code></pre>
must be contained in context as it provides the necessary gRPC routing to the Hedera Network’s node, which is not encoded in the signed network transaction structure.
Declaration
public static Task<TransactionReceipt> SubmitExternalTransactionAsync(this ConsensusClient client, ExternalTransactionParams externalParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client submitting the raw networkTransaction to the network. |
| ExternalTransactionParams | externalParams |
|
| 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 receipt for the submitted network transaction, if successful, otherwise an exception is thrown. |
Remarks
Note: this method accepts protobuf encoded as a
SignedTransaction
, not a
Transaction
object as the network transaction object contains deprecated protobuf fields not supported by this SDK. The method will perform the necessary final wrapping of the network transaction for final submission.
Examples
// Use the params overload to layer additional signatures on top of
// an externally-signed transaction without re-building the body.
// Any Signatory in the client's context is also applied.
var receipt = await client.SubmitExternalTransactionAsync(new ExternalTransactionParams
{
SignedTransactionBytes = signedBytes,
Signatory = extraSignatory
});
Console.WriteLine($"Status: {receipt.Status}");
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If required arguments are missing. |
| InvalidOperationException | If required context configuration is missing. |
| PrecheckException | If the gateway node create rejected the request upon submission. |
| ConsensusException | If the network was unable to come to consensus before the duration of the networkTransaction expired. |
| TransactionException | If the network rejected the create request as invalid or had missing data. |
SubmitExternalTransactionAsync(ConsensusClient, ReadOnlyMemory<byte>, Action<IConsensusContext>?)
Submits an arbitrary externally created Hedera Transaction to the network.
The transaction is submitted as a
SignedTransaction
object, protobuf encoded, and may include signatures in the associated
<pre><code class="lang-csharp">sigMap</code></pre>
field. Any Signatories held in the client context
(or method call) will add signatures to this transaction prior to submitting.
It is not necessary to include a
Payer
in the context as the transaction itself defines the payer, however a matching (via Node Account ID)
<pre><code class="lang-csharp">ConsensusNodeEndpoint</code></pre>
must be contained in context as it provides the necessary gRPC routing to the Hedera Network’s node, which is not encoded in the signed transaction structure.
Declaration
public static Task<TransactionReceipt> SubmitExternalTransactionAsync(this ConsensusClient client, ReadOnlyMemory<byte> signedTransactionBytes, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client submitting the raw transaction to the network. |
| ReadOnlyMemory<byte> | signedTransactionBytes |
|
| 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 receipt for the submitted transaction, if successful, otherwise an exception is thrown. |
Remarks
Note: this method accepts protobuf encoded as a
SignedTransaction
, not a
Transaction
object as the transaction object contains deprecated protobuf fields not supported by this SDK. The method will perform the necessary final wrapping of the transaction for final submission.
Examples
// Same as SendExternalTransactionAsync but waits for consensus and
// returns a full TransactionReceipt. Use when the caller needs the
// typed receipt (not just the precheck code).
var receipt = await client.SubmitExternalTransactionAsync(preBuiltSignedTransactionBytes);
Console.WriteLine($"Status: {receipt.Status}");
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If required arguments are missing. |
| InvalidOperationException | If required context configuration is missing. |
| PrecheckException | If the gateway node create 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. |