Skip to Content
Ethereum Cookbook
book

Ethereum Cookbook

by Manoj P R
August 2018
Intermediate to advanced
404 pages
11h 19m
English
Packt Publishing
Content preview from Ethereum Cookbook

How to do it…

  1. Whisper uses the shh protocol to send messages between DApps. In Web3JS, you can directly access the object from the root:
web3.shh
  1. Create a new identity using the shh object. Call the newIdentity function to do this:
var identity = web3.shh.newIdentity();
  1. Use the post method to broadcast the messages:
web3.shh.post({    // ...});
  1. 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Ethereum Dapps

Building Ethereum Dapps

Roberto Infante
Ethereum For Dummies

Ethereum For Dummies

Michael G. Solomon

Publisher Resources

ISBN: 9781789133998Supplemental Content