solidity – Error Fix: Current Provider Doesn’t Support Subscriptions in MetaMaskInpageProvider

eventsmetamasksolidityweb3js

I'm simply trying to setup an event listener with web3 and metamask.

  incrementEvent = existingContract.events.Incremented(function(error, event){
                  if (error) console.log(error);
                  console.log("event is: ", event);
                })

Result:

Error: The current provider doesn't support subscriptions: MetamaskInpageProvider
    at Subscription.subscribe (bundle.js:45443)
    at Contract._on (bundle.js:48777)
    at (index):48
    at tryCatcher (bundle.js:44235)
    at Promise._settlePromiseFromHandler (bundle.js:42267)
    at Promise._settlePromise (bundle.js:42325)
    at Promise._settlePromise0 (bundle.js:42370)
    at Promise._settlePromises (bundle.js:42453)
    at bundle.js:39334
    at MutationObserver.<anonymous> (bundle.js:43502)
(index):50 event is: null

How do you listen to contract events with metamask?

Best Answer

There are some issues with the way metamask handles events currently.

Until those issues are solved you can try use another provider just for handling events. You would need to instantiate another web3 instance with another provider. The provider could be our own node or infura for example.

Related Topic