3

The following seems to poll my Ethereum node every second:

web3.eth.contract(contractAbi).at(contractAddress).allEvents(callback);

Is there a way to decrease the polling interval?

hohoho
  • 293
  • 1
  • 2
  • 10

1 Answers1

2

Indeed you need to use WebsocketProvider, it gives you opportunity to receive notification instantly after node synchronization.

var web3 = new Web3(new Web3.providers.WebsocketProvider('wss://ropsten.infura.io/ws'));

var myContract = new web3.eth.Contract(<abi>, <address>);
myContract.events.allEvents({ fromBlock: 'latest' }, console.log);
Aquila
  • 1,812
  • 1
  • 10
  • 23