- Whisper uses the shh protocol to send messages between DApps. In Web3JS, you can directly access the object from the root:
web3.shh
- Create a new identity using the shh object. Call the newIdentity function to do this:
var identity = web3.shh.newIdentity();
- Use the post method to broadcast the messages:
web3.shh.post({ // ...});
- Every post method accepts a JSON object with the following parameters:
- topic: One or multiple arbitrary data items that are used to encode the abstract topic of this message. It can be used to filter messages based on requirements.
- payload: Unformatted byte array that provides the data to be sent. Similar to topic.
- TTL: Time for the message to live on the network in seconds. This defaults to ...