Show / Hide Table of Contents

Class SubmitMessageExtensions

Extension methods for submitting messages to consensus topics.

Inheritance
object
SubmitMessageExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class SubmitMessageExtensions

Methods

| Edit this page View Source

SubmitMessageAsync(ConsensusClient, EntityId, ReadOnlyMemory<byte>, Action<IConsensusContext>?)

Sends a message to the network for a given consensus topic.

Declaration
public static Task<SubmitMessageReceipt> SubmitMessageAsync(this ConsensusClient client, EntityId topic, ReadOnlyMemory<byte> message, Action<IConsensusContext>? configure = null)
Parameters
Type Name Description
ConsensusClient client

The Consensus Node Client receiving the message transaction.

EntityId topic

The address of the topic for the message.

ReadOnlyMemory<byte> message

The value of the message, limited to the 4K total network transaction size.

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<SubmitMessageReceipt>

A Submit Message Receipt indicating success, includes information about the sequence number of the message and its running hash.

Examples
var message = Encoding.UTF8.GetBytes("Hello from Hiero SDK!");
var submitReceipt = await client.SubmitMessageAsync(createReceipt.Topic, message);
Console.WriteLine($"Message submitted - Sequence: {submitReceipt.SequenceNumber}");
Console.WriteLine($"Status: {submitReceipt.Status}");
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.

| Edit this page View Source

SubmitMessageAsync(ConsensusClient, SubmitMessageParams, Action<IConsensusContext>?)

Sends a message or a segment of a message to the network for a given consensus topic. The caller of this method is responsible for managing the segment of the message and associated metadata.

Declaration
public static Task<SubmitMessageReceipt> SubmitMessageAsync(this ConsensusClient client, SubmitMessageParams submitParams, Action<IConsensusContext>? configure = null)
Parameters
Type Name Description
ConsensusClient client

The Consensus Node Client receiving the message transaction.

SubmitMessageParams submitParams

Details of the message segment to upload, including the metadata corresponding to this segment.

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<SubmitMessageReceipt>

A Submit Message Receipt indicating success, includes information about the sequence number of the message and its running hash.

Examples

Submit to a submit-key-gated topic by attaching the key via params:

// Submit a message to a submit-key-protected topic. The submit key
// goes on the params' Signatory — the simple overload has no place
// to attach it, so the params overload is required here.
var payload = Encoding.UTF8.GetBytes("Authorized message");
var receipt = await client.SubmitMessageAsync(new SubmitMessageParams
{
    Topic = topic,
    Message = payload,
    Signatory = submitKey
});
Console.WriteLine($"Sequence: {receipt.SequenceNumber}");
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.

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