Show / Hide Table of Contents

Interface IConsensusContext

A ConsensusClient instance’s configuration.

Namespace: Hiero
Assembly: Hiero.dll
Syntax
public interface IConsensusContext
Remarks

This interface exposes the current configuration context for a ConsensusClient instance. When accessed through a Configure(Action<IConsensusContext>), Clone(Action<IConsensusContext>?) or one of the network request methods, calling code can interrogate the object for configuration details and update as necessary.
Typically, the bare minimum that must be configured in a context in order to access the network are values for the Node Endpoint and Payer Address. The other default values are typically suitable for most interactions with the network.

Properties

| Edit this page View Source

AdjustForLocalClockDrift

If set to 
true

the library client will automatically scan for InvalidTransactionStart responses from the server and adjust the automatic generation of transaction IDs as appropriate to compensate for local clock drift from the network server's clock. This can help reduce the wait time for acceptance of transactions if the local clock deviates from the network time by too wide a margin. It is only recommended to enable this setting if you are having performance problems related to clock drift and are unable to resolve at the environment level. The default for this value is

false

.

Declaration
bool AdjustForLocalClockDrift { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

Endpoint

Network Payer and Node Address for gaining access to the Hedera Network.

Declaration
ConsensusNodeEndpoint? Endpoint { get; set; }
Property Value
Type Description
ConsensusNodeEndpoint
| Edit this page View Source

FeeLimit

The maximum fee the payer is willing to pay for a transaction.

Declaration
long FeeLimit { get; set; }
Property Value
Type Description
long
| Edit this page View Source

Memo

The default memo associated with transactions sent to the network.

Declaration
string? Memo { get; set; }
Property Value
Type Description
string
| Edit this page View Source

OnResponseReceived

Called by the library just after receiving a response from the server and before processing that response. The information includes a retry number, the response from the first send being 0. Subsequent numbers indicate responses from resends of the same transaction, typically in response to a BUSY response from the server or in the cases where there is some time drift between the server and the client system. This information can be useful for logging and troubleshooting efforts.

Declaration
Action<int, IMessage>? OnResponseReceived { get; set; }
Property Value
Type Description
Action<int, IMessage>
| Edit this page View Source

OnSendingRequest

Called by the library just before the serialized protobuf is sent to the Hedera Network. This is the only exposure the library provides to the underlying protobuf implementation (although they are publicly available in the library).
This method can be useful for logging and tracking purposes. It could also be used in advanced scenarios to modify the protobuf message just before sending.

Declaration
Action<IMessage>? OnSendingRequest { get; set; }
Property Value
Type Description
Action<IMessage>
| Edit this page View Source

Payer

The address of the account that pays for transactions submitted to the network, otherwise known as the "Operator".

Declaration
EntityId? Payer { get; set; }
Property Value
Type Description
EntityId
| Edit this page View Source

QueryTip

The additional amount of tinybars to add to the estimated cost of a QueryAsync when a query fee is required. Sometimes the network can under-report the required query fee. For critical application paths, this value can be used to hedge any last nanosecond changes to the cost of a query. Most use cases will not need to set this value unless they frequently see "The Network Changed the price of ..." errors in their logs.

Declaration
long QueryTip { get; set; }
Property Value
Type Description
long
| Edit this page View Source

RetryCount

The number of times the client software should retry sending a transaction to the network after the initial request failed with the server returning BUSY or invalid due to client/server time drift, or waiting for a “fast” receipt to return consensus.

Declaration
int RetryCount { get; set; }
Property Value
Type Description
int
| Edit this page View Source

RetryDelay

The timespan to wait between retry attempts. Each retry attempt adds the same additional amount of delay between retries. The second attempt will wait twice the delay, the third attempt will wait three times the delay and so on.

Declaration
TimeSpan RetryDelay { get; set; }
Property Value
Type Description
TimeSpan
| Edit this page View Source

Signatory

The private key, keys or signing callback method that are needed to sign the transaction. At a minimum, this typically includes the Payer's signing key, but can also include other signatories such as those required when creating files and contracts.

Declaration
Signatory? Signatory { get; set; }
Property Value
Type Description
Signatory
Remarks

Every key added into this context will sign every transaction made by the owning client object. This includes the "second" transaction required to obtain a record from the network when the "WithRecord" form of method calls are invoked. It is important to note that many of the API calls have additional opportunities to identify specific signatories for various transactions. It is not necessary to add all the keys on this context for say, a key rotation on an account; especially if the "WithRecord" form is invoked. It is recommended to place only the keys associated with the Payer account in this property. Not doing so may result in extraneous unnecessary signatures being sent with transactions. If this happens the transaction cost goes up due to the larger transaction size, wasting crypto due to unnecessary signature processing fees.

| Edit this page View Source

SignaturePrefixTrimLimit

The smallest desired signature map prefix value length.
The client will trim the length of signature prefix identifiers in a signature map to the smallest value possible, but not less than this value. If the value is set to 0 (the default) the minimum possible feasible value will be used when multiple signatures are added to a transaction, omitting the prefix completely if only one signature is provided. This does not guarantee a minimum length of a signature prefix (a shorter value may be provided to the client by the signing algorithm) only that the client will not actively reduce the value beyond this limit.

Declaration
int SignaturePrefixTrimLimit { get; set; }
Property Value
Type Description
int
| Edit this page View Source

ThrowIfNotSuccess

If set to 
true

(default) the library client will throw a PrecheckException or TransactionException if the response code returned from a transaction accepted by the network returns a response of anything other than Success. Queries will still throw exceptions if the operation cannot be executed without error.

Declaration
bool ThrowIfNotSuccess { get; set; }
Property Value
Type Description
bool
Remarks
For backwards compatibility, this value defaults to 
true

.

| Edit this page View Source

TransactionDuration

The maximum amount of time the client is willing to wait for consensus for a transaction, after which the submitted transaction is invalid.

Declaration
TimeSpan TransactionDuration { get; set; }
Property Value
Type Description
TimeSpan
| Edit this page View Source

TransactionId

Override the automatic generation of a transaction ID and use the given Transaction ID. Can be useful for submitting the same transaction to multiple client/gateways.

Declaration
TransactionId? TransactionId { get; set; }
Property Value
Type Description
TransactionId

Methods

| Edit this page View Source

Reset(string)

Clears a property on the context.  This is the only way to clear 
a property value on the context so that a parent value can be 
used instead.  Setting a value to 
null

does not clear the value, it sets it to

null

for the current context and child contexts.

Declaration
void Reset(string name)
Parameters
Type Name Description
string name
The name of the property to reset, must be one of the public 
properties of the 
IConsensusContext

. We suggest using the

nameof()

operator to ensure type safety.

Exceptions
Type Condition
ArgumentOutOfRangeException
when an invalid 
name

is provided.

  • Edit this page
  • View Source
In this article
Back to top .NET Client Library for Hiero Network and Hedera Hashgraph