Show / Hide Table of Contents

Class ConsensusClient

Hiero Network Consensus (Gossip) Node Client

Inheritance
object
ConsensusClient
Implements
IAsyncDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public sealed class ConsensusClient : IAsyncDisposable
Remarks

This component facilitates interaction with the Hiero Network.
It manages the communication channels with the network and serialization of requests and responses. This library generally shields the client code from directly interacting with the underlying protobuf communication layer but does provide hooks allowing advanced low-level manipulation of messages if necessary.

Constructors

| Edit this page View Source

ConsensusClient(Action<IConsensusContext>?)

Creates a new instance of a Hiero Network ConsensusClient.

Declaration
public ConsensusClient(Action<IConsensusContext>? configure = null)
Parameters
Type Name Description
Action<IConsensusContext> configure

Optional configuration method that can set the location of the network node accessing the network and how transaction fees shall be paid for.

Remarks
Creating a new instance of a 
ConsensusClient

initializes a new instance of a client. It will have a separate cache of GRPC channels to the network and will maintain a separate configuration from other clients. The constructor takes an optional callback method that configures the details on how the client should connect to the network and what accounts generally pay transaction fees and other details. See the IConsensusContext documentation for configuration details.

| Edit this page View Source

ConsensusClient(Func<ConsensusNodeEndpoint, GrpcChannel>, Action<IConsensusContext>?)

Creates a new instance of a Hiero Network ConsensusClient with a custom gRPC channel factory.

Declaration
public ConsensusClient(Func<ConsensusNodeEndpoint, GrpcChannel> channelFactory, Action<IConsensusContext>? configure = null)
Parameters
Type Name Description
Func<ConsensusNodeEndpoint, GrpcChannel> channelFactory

A custom callback method returning a new channel given the target ConsensusNodeEndpoint. Note, this method is only called once for each unique ConsensusNodeEndpoint requested by the ConsensusClient (which is a function of the current context's ConsensusNodeEndpoint parameter)

Action<IConsensusContext> configure

Optional configuration method that can set the location of the network node accessing the network and how transaction fees shall be paid for.

Remarks
Creating a new instance of a 
ConsensusClient

initializes a new instance of a client. It will have a separate cache of GRPC channels to the network and will maintain a separate configuration from other clients. The constructor takes an optional callback method that configures the details on how the client should connect to the network and what accounts generally pay transaction fees and other details. See the IConsensusContext documentation for configuration details.

Methods

| Edit this page View Source

Clone(Action<IConsensusContext>?)

Creates a new instance of the client having a shared base configuration with its parent. Changes to the parent’s configuration will reflect in this instance’s configuration while changes in this instance’s configuration will not be reflected in the parent configuration.

Declaration
public ConsensusClient Clone(Action<IConsensusContext>? configure = null)
Parameters
Type Name Description
Action<IConsensusContext> configure

The callback method receiving the IConsensusContext object providing the configuration details of this client instance. Values can be retrieved and set within the context of the method invocation.

Returns
Type Description
ConsensusClient

A new instance of a client object.

| Edit this page View Source

Configure(Action<IConsensusContext>)

Updates the configuration of this instance of a client through implementation of the supplied IConsensusContext callback method.

Declaration
public void Configure(Action<IConsensusContext> configure)
Parameters
Type Name Description
Action<IConsensusContext> configure

The callback method receiving the IConsensusContext object providing the configuration details of this client instance. Values can be retrieved and set within the context of the method invocation.

| Edit this page View Source

DisposeAsync()

.NET Asynchronous dispose method.

Declaration
public ValueTask DisposeAsync()
Returns
Type Description
ValueTask

An Async Task.

Remarks
Closes any GRPC channels solely owned by this 
ConsensusClient

instance.

| Edit this page View Source

ExecuteAsync<T>(TransactionParams<T>, Action<IConsensusContext>?)

Creates, signs, submits a transaction and waits for a response from the target consensus node, returning a receipt.

Declaration
public Task<T> ExecuteAsync<T>(TransactionParams<T> transactionParams, Action<IConsensusContext>? configure = null) where T : TransactionReceipt
Parameters
Type Name Description
TransactionParams<T> transactionParams

The details of the transaction 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<T>

A receipt object.

Type Parameters
Name Description
T

The type of receipt to return.

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

true

in the client context configuration.

ConsensusException

Under heavy load, the network may not process the transaction before it expires.

| Edit this page View Source

SubmitAsync<T>(TransactionParams<T>, Action<IConsensusContext>?)

Creates, signs, submits a 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 Task<ResponseCode> SubmitAsync<T>(TransactionParams<T> transactionParams, Action<IConsensusContext>? configure = null) where T : TransactionReceipt
Parameters
Type Name Description
TransactionParams<T> transactionParams

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.

Type Parameters
Name Description
T

The type of TransactionReceipt returned by the request.

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.

| Edit this page View Source

ToString()

Returns a human-readable debug string describing this client instance.

Declaration
public override string ToString()
Returns
Type Description
string
Overrides
object.ToString()

Implements

IAsyncDisposable

Extension Methods

AbortNetworkUpgradeExtensions.AbortNetworkUpgradeAsync(ConsensusClient, AbortNetworkUpgradeParams, Action<IConsensusContext>?)
AccountDetailExtensions.GetAccountDetailAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
AccountInfoExtensions.GetAccountInfoAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
AddConsensusNodeExtensions.AddConsensusNodeAsync(ConsensusClient, AddConsensusNodeParams, Action<IConsensusContext>?)
AirdropExtensions.AirdropAsync(ConsensusClient, AirdropParams, Action<IConsensusContext>?)
AirdropExtensions.AirdropNftAsync(ConsensusClient, Nft, EntityId, EntityId, Action<IConsensusContext>?)
AirdropExtensions.AirdropTokenAsync(ConsensusClient, EntityId, EntityId, EntityId, long, Action<IConsensusContext>?)
AllowanceExtensions.AllocateAllowanceAsync(ConsensusClient, AllowanceParams, Action<IConsensusContext>?)
AppendFileExtensions.AppendFileAsync(ConsensusClient, AppendFileParams, Action<IConsensusContext>?)
AssociateTokenExtensions.AssociateTokenAsync(ConsensusClient, EntityId, EntityId, Action<IConsensusContext>?)
AssociateTokenExtensions.AssociateTokensAsync(ConsensusClient, AssociateTokenParams, Action<IConsensusContext>?)
BurnNftExtensions.BurnNftAsync(ConsensusClient, Nft, Action<IConsensusContext>?)
BurnNftExtensions.BurnNftsAsync(ConsensusClient, BurnNftParams, Action<IConsensusContext>?)
BurnTokenExtensions.BurnTokensAsync(ConsensusClient, BurnTokenParams, Action<IConsensusContext>?)
BurnTokenExtensions.BurnTokensAsync(ConsensusClient, EntityId, ulong, Action<IConsensusContext>?)
CallContractExtensions.CallContractAsync(ConsensusClient, CallContractParams, Action<IConsensusContext>?)
CancelAirdropExtensions.CancelAirdropAsync(ConsensusClient, Airdrop, Action<IConsensusContext>?)
CancelAirdropExtensions.CancelAirdropsAsync(ConsensusClient, CancelAirdropParams, Action<IConsensusContext>?)
ClaimAirdropExtensions.ClaimAirdropAsync(ConsensusClient, Airdrop, Action<IConsensusContext>?)
ClaimAirdropExtensions.ClaimAirdropsAsync(ConsensusClient, ClaimAirdropParams, Action<IConsensusContext>?)
ConfiscateNftExtensions.ConfiscateNftAsync(ConsensusClient, Nft, EntityId, Action<IConsensusContext>?)
ConfiscateNftExtensions.ConfiscateNftsAsync(ConsensusClient, ConfiscateNftParams, Action<IConsensusContext>?)
ConfiscateTokenExtensions.ConfiscateTokensAsync(ConsensusClient, ConfiscateTokenParams, Action<IConsensusContext>?)
ConfiscateTokenExtensions.ConfiscateTokensAsync(ConsensusClient, EntityId, EntityId, ulong, Action<IConsensusContext>?)
ConsensusNodeInfoExtensions.GetAddressBookAsync(ConsensusClient, CancellationToken, Action<IConsensusContext>?)
ContinueTokenExtensions.ContinueTokenAsync(ConsensusClient, ContinueTokenParams, Action<IConsensusContext>?)
ContinueTokenExtensions.ContinueTokenAsync(ConsensusClient, EntityId, Action<IConsensusContext>?)
ContractBalancesExtensions.GetAccountBalanceAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
ContractBalancesExtensions.GetAccountBalancesAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
ContractBalancesExtensions.GetContractBalanceAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
ContractBalancesExtensions.GetContractBalancesAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
ContractInfoExtensions.GetContractBytecodeAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
ContractInfoExtensions.GetContractInfoAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
CreateAccountExtensions.CreateAccountAsync(ConsensusClient, CreateAccountParams, Action<IConsensusContext>?)
CreateContractExtensions.CreateContractAsync(ConsensusClient, CreateContractParams, Action<IConsensusContext>?)
CreateFileExtensions.CreateFileAsync(ConsensusClient, CreateFileParams, Action<IConsensusContext>?)
CreateNftExtensions.CreateNftAsync(ConsensusClient, CreateNftParams, Action<IConsensusContext>?)
CreateTokenExtensions.CreateTokenAsync(ConsensusClient, CreateTokenParams, Action<IConsensusContext>?)
CreateTopicExtensions.CreateTopicAsync(ConsensusClient, CreateTopicParams, Action<IConsensusContext>?)
DeleteAccountExtensions.DeleteAccountAsync(ConsensusClient, DeleteAccountParams, Action<IConsensusContext>?)
DeleteContractExtensions.DeleteContractAsync(ConsensusClient, DeleteContractParams, Action<IConsensusContext>?)
DeleteFileExtensions.DeleteFileAsync(ConsensusClient, DeleteFileParams, Action<IConsensusContext>?)
DeleteScheduleExtensions.DeleteScheduleAsync(ConsensusClient, DeleteScheduleParams, Action<IConsensusContext>?)
DeleteScheduleExtensions.DeleteScheduleAsync(ConsensusClient, EntityId, Action<IConsensusContext>?)
DeleteTokenExtensions.DeleteTokenAsync(ConsensusClient, DeleteTokenParams, Action<IConsensusContext>?)
DeleteTokenExtensions.DeleteTokenAsync(ConsensusClient, EntityId, Action<IConsensusContext>?)
DeleteTopicExtensions.DeleteTopicAsync(ConsensusClient, DeleteTopicParams, Action<IConsensusContext>?)
DeleteTopicExtensions.DeleteTopicAsync(ConsensusClient, EntityId, Action<IConsensusContext>?)
DissociateTokenExtensions.DissociateTokenAsync(ConsensusClient, DissociateTokenParams, Action<IConsensusContext>?)
DissociateTokenExtensions.DissociateTokenAsync(ConsensusClient, EntityId, EntityId, Action<IConsensusContext>?)
EvmTransactionExtensions.ExecuteEvmTransactionAsync(ConsensusClient, EvmTransactionParams, Action<IConsensusContext>?)
ExchangeRatesExtensions.GetExchangeRatesAsync(ConsensusClient, CancellationToken, Action<IConsensusContext>?)
ExternalExtensions.PrepareExternalTransactionAsync<TReceipt>(ConsensusClient, TransactionParams<TReceipt>, Action<IConsensusContext>?)
ExternalExtensions.QueryExternalAsync(ConsensusClient, ReadOnlyMemory<byte>, CancellationToken, Action<IConsensusContext>?)
ExternalTransactionParamsExtensions.SendExternalTransactionAsync(ConsensusClient, ExternalTransactionParams, Action<IConsensusContext>?)
ExternalTransactionParamsExtensions.SendExternalTransactionAsync(ConsensusClient, ReadOnlyMemory<byte>, CancellationToken, Action<IConsensusContext>?)
ExternalTransactionParamsExtensions.SubmitExternalTransactionAsync(ConsensusClient, ExternalTransactionParams, Action<IConsensusContext>?)
ExternalTransactionParamsExtensions.SubmitExternalTransactionAsync(ConsensusClient, ReadOnlyMemory<byte>, Action<IConsensusContext>?)
FeeSchedulesExtensions.GetFeeScheduleAsync(ConsensusClient, CancellationToken, Action<IConsensusContext>?)
FileInfoExtensions.GetFileContentAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
FileInfoExtensions.GetFileInfoAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
GrantTokenKycExtensions.GrantTokenKycAsync(ConsensusClient, EntityId, EntityId, Action<IConsensusContext>?)
GrantTokenKycExtensions.GrantTokenKycAsync(ConsensusClient, GrantTokenKycParams, Action<IConsensusContext>?)
MintNftExtensions.MintNftAsync(ConsensusClient, EntityId, ReadOnlyMemory<byte>, Action<IConsensusContext>?)
MintNftExtensions.MintNftsAsync(ConsensusClient, MintNftParams, Action<IConsensusContext>?)
MintTokenExtensions.MintTokenAsync(ConsensusClient, EntityId, ulong, Action<IConsensusContext>?)
MintTokenExtensions.MintTokenAsync(ConsensusClient, MintTokenParams, Action<IConsensusContext>?)
NftInfoExtensions.GetNftInfoAsync(ConsensusClient, Nft, CancellationToken, Action<IConsensusContext>?)
PauseTokenExtensions.PauseTokenAsync(ConsensusClient, EntityId, Action<IConsensusContext>?)
PauseTokenExtensions.PauseTokenAsync(ConsensusClient, PauseTokenParams, Action<IConsensusContext>?)
PrepareNetworkUpgradeExtensions.PrepareNetworkUpgradeAsync(ConsensusClient, PrepareNetworkUpgradeParams, Action<IConsensusContext>?)
PseudoRandomNumberExtensions.GeneratePseudoRandomNumberAsync(ConsensusClient, PseudoRandomNumberParams, Action<IConsensusContext>?)
QueryContractExtensions.QueryContractAsync(ConsensusClient, QueryContractParams, Action<IConsensusContext>?)
RelinquishTokenExtensions.RelinquishAsync(ConsensusClient, RelinquishTokensParams, Action<IConsensusContext>?)
RelinquishTokenExtensions.RelinquishNftAsync(ConsensusClient, Nft, Action<IConsensusContext>?)
RelinquishTokenExtensions.RelinquishTokenAsync(ConsensusClient, EntityId, Action<IConsensusContext>?)
RemoveConsensusNodeExtensions.RemoveConsensusNodeAsync(ConsensusClient, RemoveConsensusNodeParams, Action<IConsensusContext>?)
RemoveConsensusNodeExtensions.RemoveConsensusNodeAsync(ConsensusClient, ulong, Action<IConsensusContext>?)
ResumeTokenExtensions.ResumeTokenAsync(ConsensusClient, EntityId, EntityId, Action<IConsensusContext>?)
ResumeTokenExtensions.ResumeTokenAsync(ConsensusClient, ResumeTokenParams, Action<IConsensusContext>?)
RevokeNftAllowanceExtensions.RevokeNftAllowancesAsync(ConsensusClient, RevokeNftAllowanceParams, Action<IConsensusContext>?)
RevokeTokenKycExtensions.RevokeTokenKycAsync(ConsensusClient, EntityId, EntityId, Action<IConsensusContext>?)
RevokeTokenKycExtensions.RevokeTokenKycAsync(ConsensusClient, RevokeTokenKycParams, Action<IConsensusContext>?)
ScheduleExtensions.ScheduleAsync(ConsensusClient, ScheduleParams, Action<IConsensusContext>?)
ScheduleExtensions.ScheduleAsync(ConsensusClient, TransactionParams, Action<IConsensusContext>?)
ScheduleExtensions.SubmitAsync(ConsensusClient, ScheduleParams, Action<IConsensusContext>?)
ScheduleInfoExtensions.GetScheduleInfoAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
ScheduleNetworkUpgradeExtensions.ScheduleNetworkUpgradeAsync(ConsensusClient, ScheduleNetworkUpgradeParams, Action<IConsensusContext>?)
ScheduleTelemetryUpgradeExtensions.ScheduleTelemetryUpgradeAsync(ConsensusClient, ScheduleTelemetryUpgradeParams, Action<IConsensusContext>?)
SignScheduleExtensions.SignScheduleAsync(ConsensusClient, EntityId, Action<IConsensusContext>?)
SignScheduleExtensions.SignScheduleAsync(ConsensusClient, SignScheduleParams, Action<IConsensusContext>?)
SubmitMessageExtensions.SubmitMessageAsync(ConsensusClient, EntityId, ReadOnlyMemory<byte>, Action<IConsensusContext>?)
SubmitMessageExtensions.SubmitMessageAsync(ConsensusClient, SubmitMessageParams, Action<IConsensusContext>?)
SuspendNetworkExtensions.SuspendNetworkAsync(ConsensusClient, SuspendNetworkParams, Action<IConsensusContext>?)
SuspendTokenExtensions.SuspendTokenAsync(ConsensusClient, EntityId, EntityId, Action<IConsensusContext>?)
SuspendTokenExtensions.SuspendTokenAsync(ConsensusClient, SuspendTokenParams, Action<IConsensusContext>?)
SystemDeleteContractExtensions.SystemDeleteContractAsync(ConsensusClient, SystemDeleteContractParams, Action<IConsensusContext>?)
SystemDeleteFileExtensions.SystemDeleteFileAsync(ConsensusClient, SystemDeleteFileParams, Action<IConsensusContext>?)
SystemRestoreContractExtensions.SystemRestoreContractAsync(ConsensusClient, SystemRestoreContractParams, Action<IConsensusContext>?)
SystemRestoreFileExtensions.SystemRestoreFileAsync(ConsensusClient, SystemRestoreFileParams, Action<IConsensusContext>?)
TokenInfoExtensions.GetTokenInfoAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
TopicInfoExtensions.GetTopicInfoAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
TransactionBatchParamsExtensions.ExecuteAsync(ConsensusClient, BatchedTransactionParams, Action<IConsensusContext>?)
TransactionBatchParamsExtensions.SubmitAsync(ConsensusClient, BatchedTransactionParams, Action<IConsensusContext>?)
TransactionReceiptExtensions.GetAllReceiptsAsync(ConsensusClient, TransactionId, CancellationToken, Action<IConsensusContext>?)
TransactionReceiptExtensions.GetReceiptAsync(ConsensusClient, TransactionId, CancellationToken, Action<IConsensusContext>?)
TransactionRecordExtensions.GetAccountRecordsAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
TransactionRecordExtensions.GetAllTransactionRecordsAsync(ConsensusClient, TransactionId, CancellationToken, Action<IConsensusContext>?)
TransactionRecordExtensions.GetTransactionRecordAsync(ConsensusClient, TransactionId, CancellationToken, Action<IConsensusContext>?)
TransferExtensions.TransferAsync(ConsensusClient, EntityId, EntityId, long, Action<IConsensusContext>?)
TransferExtensions.TransferAsync(ConsensusClient, TransferParams, Action<IConsensusContext>?)
TransferExtensions.TransferNftAsync(ConsensusClient, Nft, EntityId, EntityId, Action<IConsensusContext>?)
TransferExtensions.TransferTokensAsync(ConsensusClient, EntityId, EntityId, EntityId, long, Action<IConsensusContext>?)
UpdateAccountExtensions.UpdateAccountAsync(ConsensusClient, UpdateAccountParams, Action<IConsensusContext>?)
UpdateConsensusNodeExtensions.UpdateConsensusNodeAsync(ConsensusClient, UpdateConsensusNodeParams, Action<IConsensusContext>?)
UpdateContractExtensions.UpdateContractAsync(ConsensusClient, UpdateContractParams, Action<IConsensusContext>?)
UpdateFileExtensions.UpdateFileAsync(ConsensusClient, UpdateFileParams, Action<IConsensusContext>?)
UpdateHookStorageExtensions.UpdateHookStorageAsync(ConsensusClient, UpdateHookStorageParams, Action<IConsensusContext>?)
UpdateNftsExtensions.UpdateNftMetadataAsync(ConsensusClient, Nft, ReadOnlyMemory<byte>, Action<IConsensusContext>?)
UpdateNftsExtensions.UpdateNftsMetadataAsync(ConsensusClient, UpdateNftsParams, Action<IConsensusContext>?)
UpdateRoyaltiesExtensions.UpdateRoyaltiesAsync(ConsensusClient, EntityId, IReadOnlyList<IRoyalty>?, Action<IConsensusContext>?)
UpdateRoyaltiesExtensions.UpdateRoyaltiesAsync(ConsensusClient, UpdateRoyaltiesParams, Action<IConsensusContext>?)
UpdateTokenExtensions.UpdateTokenAsync(ConsensusClient, UpdateTokenParams, Action<IConsensusContext>?)
UpdateTopicExtensions.UpdateTopicAsync(ConsensusClient, UpdateTopicParams, Action<IConsensusContext>?)
UtilityExtensions.CreateNewTransactionId(ConsensusClient, Action<IConsensusContext>?)
UtilityExtensions.PingAsync(ConsensusClient, CancellationToken, Action<IConsensusContext>?)
VersionInfoExtensions.GetVersionInfoAsync(ConsensusClient, CancellationToken, Action<IConsensusContext>?)
  • Edit this page
  • View Source
In this article
Back to top .NET Client Library for Hiero Network and Hedera Hashgraph