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.
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
Please see the transaction and query fees table for base transaction fee
//Create the transactionTopicMessageSubmitTransaction transaction =newTopicMessageSubmitTransaction().setTopicId(newTopicId).setMessage("hello, HCS! ");//Sign with the client operator key and submit transaction to a Hedera network, get transaction IDTransactionResponse txResponse =transaction.execute(client);//Request the receipt of the transactionTransactionReceipt receipt =txResponse.getReceipt(client);//Get the transaction consensus statusStatus transactionStatus =receipt.status;System.out.println("The transaction consensus status is "+transactionStatus);//v2.0.0
//Create the transactionawaitnewTopicMessageSubmitTransaction({ topicId:createReceipt.topicId, message:"Hello World", }).execute(client);//v2.0.0
//Create the transactiontransaction :=hedera.NewTopicSubmitTransaction().SetTopicID(topicID).SetMessage([]byte(content))//Sign with the client operator private key and submit the transaction to a Hedera networktxResponse, err :=transaction.Execute(client)if err != nil {panic(err)}//Request the receipt of the transactiontransactionReceipt, err :=txResponse.GetReceipt(client)if err != nil {panic(err)}//Get the transaction consensus statustransactionStatus :=receipt.Statusfmt.Printf("The transaction consensus status is %v\n", transactionStatus)//v2.0.0
Get transaction values
Method
Type
Description
getTopicId()
TopicId
The topic ID to submit the message to
getMessage()
ByteString
The message being submitted
getAllTransactionHash()
byte [ ]
The hash for each transaction
//Create the transactionTopicMessageSubmitTransaction transaction =newTopicMessageSubmitTransaction().setTopicId(newTopicId).setMessage("hello, HCS! ");//Get the transaction messageByteString getMessage =transaction.getMessage();//v2.0.0
//Create the transactionconsttransaction=awaitnewTopicMessageSubmitTransaction().setTopicId(newTopicId).setMessage("hello, HCS! ");//Get the transaction messageconstgetMessage=transaction.getMessage();//v2.0.0
//Create the transactiontransaction := hedera.NewTopicSubmitTransaction().SetTopicID(topicID).SetMessage([]byte(content))//Get the transaction messagegetMessage := transaction.GetMessage()//v2.0.0