Class AddConsensusNodeExtensions
Extension methods for adding consensus nodes to the network address book.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class AddConsensusNodeExtensions
Methods
| Edit this page View SourceAddConsensusNodeAsync(ConsensusClient, AddConsensusNodeParams, Action<IConsensusContext>?)
Creates a new consensus node in the network address book.
Declaration
public static Task<ConsensusNodeReceipt> AddConsensusNodeAsync(this ConsensusClient client, AddConsensusNodeParams createParams, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client orchestrating the request. |
| AddConsensusNodeParams | createParams | The parameters describing the new node 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<ConsensusNodeReceipt> | A receipt containing the newly assigned node identifier. |
Remarks
This is a privileged transaction requiring Hedera governing council authorization. The node becomes active after the next network upgrade.
Examples
// Register a new consensus node in the network address book. Only
// a council-privileged payer can invoke this. The receipt carries
// the network-assigned NodeId which is required by all later
// UpdateConsensusNode / RemoveConsensusNode calls.
var receipt = await client.AddConsensusNodeAsync(new AddConsensusNodeParams
{
Account = newNodeAccount,
Description = "Regional operator node",
GossipEndpoints = new[] { new Uri("tcp://10.0.0.1:50111") },
ServiceEndpoints = new[] { new Uri("https://rpc.example.com:50211") },
GossipCaCertificate = gossipCaCert,
AdminKey = nodeAdminKey,
DeclineReward = false
});
Console.WriteLine($"Assigned NodeId: {receipt.NodeId}");
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 request as invalid or had missing data. |