Post a Message
Messages
A message is an encapsulating data structure that is being actually broadcast across the network. It is an atomic unit that is either accepted or rejected as a whole.
The simplest message you can broadcast is a message without any particular payload, as shown in the following examples.
- Java
- Nodejs
- Python
- Rust
- Wasm
You can use the Client.message()
to easily send any
message over the network. Alternatively, there is a convenient
MessageSender helper class with chaining calls that prepares a message
instance and broadcasts it over the network.
loading...
Output example:
{
message: {
networkId: '14379272398717627559',
parentMessageIds: [
'03ddc83fad172a322fb00fb4e449436e9d1117ff390879100647c650a30c2d52',
'252798210fa9816f6fd40f1b19095da9f2dc88ae06fc4c0523a928a29d0d782e',
'a8e4f4cd49227068424ead8da187a48fdaa7ce8ffc4b9ac0ee2d5d3f2fcd7e70',
'dbbc8044bc624b3378e1dda83ab95f9be468b06a6a9806c76a70353182028cf9'
],
payload: null,
nonce: '9223372036854784215'
},
messageId: '10dbee9cf3c58507725861b34ac711058dc13f709be1a6d21f1dc0af17b06379'
}
messageId
is a unique id that refers to the given message in the network.
You can use the function Client.postMessage(message)
to send a message instance over a network. Alternatively, you can
use the MessageSender
helper class with chaining calls that prepares a message instance and broadcasts it over the
network.
loading...
Output example:
{
message: {
networkId: '14379272398717627559',
parentMessageIds: [
'03ddc83fad172a322fb00fb4e449436e9d1117ff390879100647c650a30c2d52',
'252798210fa9816f6fd40f1b19095da9f2dc88ae06fc4c0523a928a29d0d782e',
'a8e4f4cd49227068424ead8da187a48fdaa7ce8ffc4b9ac0ee2d5d3f2fcd7e70',
'dbbc8044bc624b3378e1dda83ab95f9be468b06a6a9806c76a70353182028cf9'
],
payload: null,
nonce: '9223372036854784215'
},
messageId: '10dbee9cf3c58507725861b34ac711058dc13f709be1a6d21f1dc0af17b06379'
}
messageId
is a unique id that refers to the given message in the network.
You can use the
Client.message()
function to prepare a message instance and send it over a network. It accepts wide range of input parameters and can
help with any kind of message type you want to broadcast.
loading...
Output example:
{
"message_id":"e2daa4c6b012b615becd6c12189b2c9e701ba0d53b31a15425b21af5105fc086",
"network_id":7712883261355838377,
"parents":[
"0e2705ce50fec88f896663d4b7d562e74cbcfdd951ac482b1f03cfa5f27396d7",
"0f5a0b2041766127c3f3bff2dd653b450b72e364765fcc805a40423c59ed01f9",
"20635b30aee437575d7e6abdf6629eec80543bee30848b0abdda2200fc11a977",
"da97cd6cfcbb854b8fd3f064c8459c5c9eae80dbd5ef594a3e1a26dcb8fc078c"
],
"payload":"None",
"nonce":2305843009213869242
}
message_id
is a unique id that refers to the given message in the network.- Every message in the Tangle should refer to up to 8 other messages. These are indicated in the
parents
section. - No actual
payload
was given in this example message (payload=None
). nonce
refer to a result of proof-of-work.
The function
Client.postMessage( message: &Message)
accepts a message instance as a parameter and sends it over a network.
loading...
Output example:
{
message: {
networkId: '14379272398717627559',
parentMessageIds: [
'03ddc83fad172a322fb00fb4e449436e9d1117ff390879100647c650a30c2d52',
'252798210fa9816f6fd40f1b19095da9f2dc88ae06fc4c0523a928a29d0d782e',
'a8e4f4cd49227068424ead8da187a48fdaa7ce8ffc4b9ac0ee2d5d3f2fcd7e70',
'dbbc8044bc624b3378e1dda83ab95f9be468b06a6a9806c76a70353182028cf9'
],
payload: null,
nonce: '9223372036854784215'
},
messageId: '10dbee9cf3c58507725861b34ac711058dc13f709be1a6d21f1dc0af17b06379'
}
messageId
is a unique id that refers to the given message in the network.
The function Client.postMessage(message)
accepts a message instance as a parameter and sends it over a network. Alternatively, there is a convenient
MessageBuilder helper class with chaining calls that prepares a
message instance and broadcasts it over the network.
loading...
Output example:
{
message: {
networkId: '14379272398717627559',
parentMessageIds: [
'03ddc83fad172a322fb00fb4e449436e9d1117ff390879100647c650a30c2d52',
'252798210fa9816f6fd40f1b19095da9f2dc88ae06fc4c0523a928a29d0d782e',
'a8e4f4cd49227068424ead8da187a48fdaa7ce8ffc4b9ac0ee2d5d3f2fcd7e70',
'dbbc8044bc624b3378e1dda83ab95f9be468b06a6a9806c76a70353182028cf9'
],
payload: null,
nonce: '9223372036854784215'
},
messageId: '10dbee9cf3c58507725861b34ac711058dc13f709be1a6d21f1dc0af17b06379'
}
messageId
is a unique id that refers to the given message in the network.