Whisper–communication protocol for DApps
Whisper is a communication protocol for DApps, which they use to communicate with each other. There are various use cases in which a communication protocol like Whisper is essential. With the help of this protocol, applications like chat rooms can be built on Ethereum.
In this recipe, you will learn more about the Whisper protocol.
Getting ready
You need to have knowledge of Ethereum network setup and usage to get the best out of this recipe. You can learn more about these initial configurations in Chapter 1, Getting Started.
Whisper is still in the development stage and is not yet recommended for production applications.
How to do it…
- Whisper uses the
shh
protocol to send messages between DApps. InWeb3JS
, you can directly access the object from the root:
web3.shh
- Create a new identity using the
shh
object. Call thenewIdentity
function to do this:
var identity = web3.shh.newIdentity();
- Use the
post
method to broadcast the messages:
web3.shh.post({ //...