Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web3.shh.post example update #3668

Merged
merged 5 commits into from
Aug 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/web3-shh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -759,25 +759,25 @@ Example

.. code-block:: javascript

var identities = [];
var identities = {};
var subscription = null;

Promise.all([
web3.shh.newSymKey().then((id) => {identities.push(id);}),
web3.shh.newKeyPair().then((id) => {identities.push(id);})
web3.shh.newSymKey().then((id) => {identities.symKey = id;}),
web3.shh.newKeyPair().then((id) => {identities.keyPair = id;})

]).then(() => {

// will receive also its own message send, below
subscription = shh.subscribe("messages", {
symKeyID: identities[0],
subscription = web3.shh.subscribe("messages", {
symKeyID: identities.symKey,
topics: ['0xffaadd11']
}).on('data', console.log);

}).then(() => {
web3.shh.post({
symKeyID: identities[0], // encrypts using the sym key ID
sig: identities[1], // signs the message using the keyPair ID
symKeyID: identities.symKey, // encrypts using the sym key ID
sig: identities.keyPair, // signs the message using the keyPair ID
ttl: 10,
topic: '0xffaadd11',
payload: '0xffffffdddddd1122',
Expand Down