Contract that uses InfuraProvider sends a transaction instead of calling the view contract function
See original GitHub issueAs stated, deploy a contract with a view function. Get the provider like
const provider = new ethers.providers.InfuraProvider('rinkeby', PROJECT_ID);
const contract = new ethers.Contract(CONTRACT_ADDRESS, ABI, provider);
await contract.getListOfThingsForExample();
Then it throws this error
{
...
reason: 'sending a transaction require a signer',
code: 'UNSUPPORTED_OPERATION',
operation: 'sendTransaction'
}
Since this is a query, it shouldn’t require a signer. Which means contract is trying to send a transaction
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How do I send contract transactions? · Issue #461 · ethers-io ...
I want to send a contract transaction through infura provider, but I need a signer to do so. The problem is that the...
Read more >What is the difference between a transaction and a call?
A call is a local invocation of a contract function that does not broadcast or publish anything on the blockchain. It is a...
Read more >Ethereum JavaScript Libraries: web3.js vs. ethers.js (Part II)
We will be using Infura to deploy our contract to the testnet so we can ... view the UINT, which is done by...
Read more >Providers — ethers.js 4.0.0 documentation
A Provider abstracts a connection to the Ethereum blockchain, for issuing queries and sending signed state changing transactions. The EtherscanProvider and ...
Read more >Documentation - Ethers.js
The Contract object makes it easier to use an on-chain Contract as a normal ... "function balanceOf(address) view returns (uint)", // Send some...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Seems like I was using v4.0 beta. Installed 5.0.32 and it’s working now. Thanks!
Can you make sure your ABI correctly specifies that getListOfThingsExample is correctly marked as view or peer?