2

I'm using "web3": "^1.2.4"

This is how I connect to 'wss://kovan.infura.io/ws'

const web3 = new Web3(new Web3.providers.WebsocketProvider('wss://kovan.infura.io/ws'))
instance = new web3.eth.Contract(ABI, ADDRESS);

Here I am trying to call PastEvents and for listening

const eventOptions = { filter: {}, fromBlock: lastBlock, toBlock: 'latest' };
const events = await instance.getPastEvents('MyEvent', eventOptions);

instance.events.MyEvent(async function (error, result) {
    console.log(result)
});

How to overcome this error?

| improve this question | | | | |
1

I had the same issue.

Turned out the Infura URL I had in my configuration file was invalid. Getting a new endpoint URL from Infura settings solved the issue.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.