What is the Whisper Protocol?

One method that apps can use to communicate with each other is via the Whisper protocol. If you’re interested in inter-dapp communication, then you might want to consider the following use cases to determine if Whisper is useful for your particular situation:

Screen Shot 2017-07-12 at 4.19.56 PM

You may want to consider using Whisper if:

  • You want your Dapp to publish small amounts of information that do not actually persist to the network, but instead live for an amount of time on the order of tens of minutes to several days.
  • Your Dapps need to communicate with each other prior to actually sending a transaction. Consider a currency exchange – two clients may need to settle a deal before actually initializing a transaction.
  • You have a Dapp that provides non-realtime updates. For instance, you might have a Dapp that publishes weather updates (although probably not, because that’s not very interesting).

Some specifics of the Whisper protocol are:

  • The API is only exposed to contracts, never to user accounts.
  • Low-bandwidth: Only designed for smaller data transfers.
  • Unpredictabe latency: Not designed for real-time communication of data.
  • 1-1 or 1-N communication.

PoW in Whisper

Whisper messages (envelopes) undergo a process called “sealing”, which basically incentivizes users to spend computational resources prior to sending the message. Internally, sealing involves hasing contents of the message repeatedly into the smallest possible number.

What this means to you as a developer is that if you want your messages to have priority over others on the network, you’ll need to spend more computational resources “sealing” them. You can specify this through the `work` parameter when posting a new message. The more work that you perform locally, the faster your message will propagate through the network.

Note that there is no way to specify exact latency times, rather you can only estimate based on how much work you perform during the “sealing” process.


TTL is the amount of time your messages live on the network, specified in seconds.


Whisper is low-level, meaning that it is identity-based instead of application-based. Messages, therefore, can be sent directly to another participant by using the recipient’s private key. Listeners on the other hand, can filter messages by specific senders or specific topics.

With `web3` you can listen for Whisper messages like this:

var replyWatch = shh.watch({
“topics”: [ web3.fromAscii(nameOfApp), identity ],
“to”: identity

replyWatch.arrived(function(m) {
// m.payload
// m.from

Sending a message

Finally, mainly for completeness, we end with an example of sending a message using Whisper:

var shh = web3.shh;
var appName = “My neat app!”;
var myName = “wheresmycookie”;
var myIdentity = shh.newIdentity();

“from”: myIdentity,
“topics”: [ web3.fromAscii(appName) ],
“payload”: [ web3.fromAscii(myName), web3.fromAscii(“What is your name?”) ],
“ttl”: 250,
“priority”: 1200

Happy whispering!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s