I have a problem getting past events of a contract on polygon, Optimism and Arbitrum. the same code works perfectly on ethereum but for some reason i cant get it to work on polygon, OP and ARB. I have tried different methods, using web3js, and ethers but no luck.

events = await Contract.getPastEvents("Borrow", {
        filter: {},
        fromBlock: startBlock,
        toBlock: "latest",

start block is current block minus some blocks, I have tried even from block 1, block 0, block -100, "earliest" you name it, but every single time, it returns an empty array.

this is the code for ethers that i tried and works on ethereum network but not polygon, OP and ARB.

const filter = Contract.filters.Borrow(null, null, null);
// const filter = Contract.filters.Borrow(); also this
events = await Contract.queryFilter(

P.S: the contract has that event, alot of it as the matter of fact and shows on those network scan. also my provider is alchemy and it works correctly (i can call view functions and it works on all mentioned networks, just event is the problem)

appreciate any help.

  • Can we see a little more context? Like, your contract address on both chains or how you initialize your contract in web3js.
    – Yetik
    Oct 11, 2022 at 10:46
  • 1
    Can you provide a minimal reproducible example? Did you try using a different provider?
    – Ismael
    Oct 12, 2022 at 4:11
  • 2
    @Ismael , Yeah when i changed the provider it worked. thanks bro. not sure why, but infura works ok.
    – Mostafa
    Oct 12, 2022 at 4:58

2 Answers 2


@Ismael points out to change the provider and when I have changed the provider, the code works correctly.


This can be caused by many reasons. Hard to answer without having more context like your contract addresses on both chains and your code that is initiliazing the contract.

Once I had a problem similar to this. Later I found out that, the event in my contract in the side chain has 1 more topic added to it. And, the ABI I'm using is not compatible. I changed the ABI to match the side chain and it worked. You should check ABI from both etherscan and polygonscan to see if they are identical or not. You can use any text comparision app online to not miss any single character changed or capital letters.

  • thanks for the response. I try to get Borrow event from aave contracts, i've already checked the ABI and it works fine, (i can do all other interaction with the contract except events). ``` Contract = new w3.eth.Contract(ABI, Address); ``` the contract address on polygon is this: 0x794a61358D6845594F94dc1DB02A252b5b4814aD let me know if i can provide more info
    – Mostafa
    Oct 11, 2022 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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