My goal is to send a message from one ethereum node to another one. In order to accomplish it, I have followed this answer that uses Whisper Protocol.

In summary approach I followed from the linked answer above:

On the receiver node:

> var kId = web3.shh.newKeyPair();
> web3.shh.newMessageFilter(
    function(err, res) {console.log(JSON.stringify(res))});
> web3.shh.getPublicKey(kId) //returns PUBLIC_KEY_OF_THE_RECEIVER

On the sender node:

  ttl: 7,
  topic: '0x07678231',
  powTarget: 2.01,
  powTime: 2,
  payload: web3.fromAscii("Hello there!")

But I obtain following message on my receiver node and I do not see Hello there! string.


I guess payload contains the sent string. "payload":"0x48656c6c6f20746865726521".

[Q] Is there any way to decode this message to obtain the original sent message?

1 Answer 1


res.payload stores the sender's sent message. We need to convert type of res.payload: from ascii into Utf8.

On the receiver node I have make following changes and I can see the sender's original message:

var kId = web3.shh.newKeyPair();
    function(err, res) {console.log(web3.toUtf8(res.payload)) 
    //function(err, res) {console.log(web3.toUtf8(res.payload) + ‘,’ + JSON.stringify(res) )}); //You can also combine it with complete res string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.