Created
January 2, 2022 00:43
-
-
Save eum602/5aba58276ef143c66128762752f06db5 to your computer and use it in GitHub Desktop.
Listen events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Web3 = require('web3'); | |
let web3 = new Web3('ws://localhost:8546'); | |
//console.log(web3); | |
var subscription = web3.eth.subscribe('logs', { | |
address: '0x77Db09300A503F5b4828dC12b57659c6ba945Cff', | |
topics: ['0x9ec8254969d1974eac8c74afb0c03595b4ffe0a1d7ad8a7f82ed31b9c8542591'] | |
}, function(error, result){ | |
if (!error) | |
console.log("Pringing some result: \n" + JSON.stringify(result)); | |
}); | |
//https://web3js.readthedocs.io/en/v1.3.0/web3-eth-subscribe.html | |
/* | |
// unsubscribes the subscription | |
subscription.unsubscribe(function(error, success){ | |
if(success) | |
console.log('Successfully unsubscribed!'); | |
});*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment