Skip to main content
A transaction that submits a topic message to the Hedera network. To access the messages submitted to a topic ID, subscribe to the topic via a mirror node. The mirror node will publish the ordered messages to subscribers. Once the transaction is successfully executed, the receipt of the transaction will include the topic’s updated sequence number and topic running hash.

Max Chunks

The max chunks setting defines the maximum number of chunks into which a given message can be split. The default value is 20 chunks, meaning a message can consist of up to 20 chunks by default. This value can be modified using the setMaxChunks method.

Max Chunk Size

🚨 NOTE: Max size of an HCS message: 1024 bytes (1 kb).
The max chunk size refers to the maximum size (in bytes) of each individual chunk of a message. By default, the max chunk size is 1024 bytes (1 KB). This value can be modified using the setChunkSize method.

Custom Fee Payment

If a topic has custom fees enabled, users submitting messages must pay the required fee in HBAR or HTS fungible tokens. If setCustomFees is not specified in the transaction, the user would need to pay any fee associated with that topic ID. The transaction will only fail if the user does not have sufficient assets to cover the fee. Recommendation: To avoid unexpected fees, it is strongly recommended to use setCustomFees when submitting a message. This ensures that only the intended fee structure is applied, providing a safeguard against unintended charges.
TopicMessageSubmitTransaction()
   .setTopicId(<TOPIC_ID>)
   .setMessage(<MESSAGE>)
   .setCustomFees(<MAX_CUSTOM_FEES>) // Ensure this covers the required amount
   .execute(client);

Transaction Signing Requirements

  • Anyone can submit a message to a public topic.
  • The submitKey is required to sign the transaction for a private topic.

Transaction Fees

⚠️ Upcoming Price Change – ConsensusSubmitMessage

Starting January 2026, the price for the ConsensusSubmitMessage transaction will increase from 0.0001to0.0001** to **0.0008 USD. This change will take effect with the v0.69 mainnet release and applies only to ConsensusSubmitMessage transactions. This update improves the long-term economic sustainability of the Hedera network while preserving predictable and USD-fixed pricing for developers. Read this blog article for more information.
  • Each transaction incurs a standard Hedera network fee based on network resource usage.
  • If a custom fee is set for a topic, users submitting messages must pay this fee in HBAR or HTS tokens.
  • The Fee Schedule Key allows authorized users to update fee structures. If set, it must sign transactions modifying fees.
  • If the topic has custom fees, the sender must have sufficient balance to cover the fees unless they are exempt via the Fee Exempt Key List. It is recommended to use setCustomFees on the TopicMessageSubmitTransaction to ensure the expected fee structure is applied and avoid unexpected transaction failures due to insufficient funds.
  • If you submit a message to a topic with a custom fee, the cost changes from the baseline 0.0001USDtoroughly0.0001 USD to roughly 0.05 USD per TopicMessageSubmitTransaction.
  • Use the query fees table for the base transaction fee and the Hedera Fee Estimator to estimate standard network fees.
⚠️ Upcoming Price Change – ConsensusSubmitMessageStarting January 2026, the price for the ConsensusSubmitMessage transaction will increase from $0.0001 to $0.0008 USD. This change will take effect with the v0.69 mainnet release and applies only to ConsensusSubmitMessage transactions. This update improves the long-term economic sustainability of the Hedera network while preserving predictable and USD-fixed pricing for developers. Read this blog article for more information.

Methods

MethodTypeDescriptionRequirement
setTopicId(<topicId>)TopicIdThe topic ID to submit the message toRequired
setMessage(<message>)StringThe message in a String formatOptional
setMessage(<message>)byte [ ]The message in a byte array formatOptional
setMessage(<message>)ByteStringThe message in a ByteString formatOptional
setChunkSize()intThe max size of individual chunk for a given message. Default: 1024 bytesOptional
setMaxChunks()intThe max number of chunks a given message can be split into. Default: 20Optional
setCustomFeeLimits()List<CustomFeeLimit>The maximum custom fees the sender is willing to payOptional
addCustomFeeLimit()CustomFeeLimitAdds a custom fee limitOptional
//Create the transaction
TopicMessageSubmitTransaction transaction = new TopicMessageSubmitTransaction()
    .setTopicId(newTopicId)
    .setMessage("hello, HCS! ")
    .setMaxCustomFees(maxCustomFees); // Set max custom fees if applicable

//Sign with the client operator key and submit transaction to a Hedera network, get transaction ID
TransactionResponse txResponse = transaction.execute(client);

//Request the receipt of the transaction
TransactionReceipt receipt = txResponse.getReceipt(client);

//Get the transaction consensus status
Status transactionStatus = receipt.status;

System.out.println("The transaction consensus status is " +transactionStatus);

//v2.0.0

Get transaction values

MethodTypeDescription
getTopicId()TopicIdThe topic ID to submit the message to
getMessage()ByteStringThe message being submitted
getCustomFeeLimits()Fee[]Extract the custom fee limits of the transaction
//Create the transaction
TopicMessageSubmitTransaction transaction = new TopicMessageSubmitTransaction()
    .setTopicId(newTopicId)
    .setMessage("hello, HCS! ");

//Get the transaction message
ByteString getMessage = transaction.getMessage();
//v2.0.0