Scope in events in web3 1.0

by Alex   Last Updated January 11, 2019 08:28 AM - source

Inside the callback of an event, how do I get the scope outside the function? Specifically, in the following scenario, I want the web3 object: (using truffle-contracts and web3 1.0 here)

...
const web3 = new Web3(someProvider);

myContract.deployed().then(function(instance) {

        //both ways work
        instance.myEvent({}, function(error, event){

            //here, I want to use web3
            web3.toAscii(event.args[0])
        })
});


Related Questions




Truffle invalid address

Updated July 31, 2017 09:28 AM


Listen to emitted event from front-end

Updated April 02, 2018 23:28 PM