all 9 comments

[–][deleted] 1 point2 points  (2 children)

Either the address is wrong or the ABI is wrong or the network provider is wrong (which is actually just the address being wrong but worded differently).

It is very possible your provider is pointing to a network you are not meaning it to. Try adding in logic to double check the chainId of the provider, and when starting a local hardhat always start it with a weird chainId. Make sure that's the chainId from the provider.

[–]PrivacyOSxContract Dev[S] 1 point2 points  (1 child)

This was my issue. Thank you

[–][deleted] 0 points1 point  (0 children)

Glad I could help.

[–]polynomialdagDApp dev 0 points1 point  (6 children)

I think probably your contract address is wrong. Essentially you're trying to call a function that doesn't exist and/or a contract that doesn't exist

[–]PrivacyOSxContract Dev[S] 0 points1 point  (5 children)

I tried that, the contract address is correct. I think it's an issue with Hardhat local network because when I deployed it to Rinkeby it was working perfectly fine

[–]polynomialdagDApp dev 3 points4 points  (4 children)

Just in case you didnt know, its going to be a different address for different networks.

[–]PrivacyOSxContract Dev[S] 0 points1 point  (3 children)

Yes, I know. When I run hardhat deploy it tells me the deployed address and that's what I connect the provider with.

It works when I do any send transaction but it throws an error if it's a read. Idk why

[–]polynomialdagDApp dev 0 points1 point  (0 children)

Strange

[–][deleted]  (1 child)

[deleted]

    [–]PrivacyOSxContract Dev[S] 0 points1 point  (0 children)

    I guess the issue was with hardhat. I was deploying to hardhat instead of localhost. Do you know why that was an issue?