-
Ethers Version5.7.2 Search TermsestimateGas, reverted, UNPREDICTABLE_GAS_LIMIT Describe the ProblemIt is not possible to estimateGas when using a provider in an ethers.contract instead of a signer.
The problem is, that the estimation call generates the following request:
The estimation fails and returns an error since it seems the estimation does not have access to msg.sender because it is missing in the request.
The same call works if I execute it with postman and adding the from address like this:
The problem is, that I cannot tell ethers, to use a specific from-address for estimation. I think I have to use a signer instead of a provider (?). Internally ethers checks if it has a signer or a provider, and if it is a provider, the from property is missing. I tried it with web3js library and here you have an option to provide a from address when calling an estimation:
This works as expected. Is there something similar for ethers? Otherwise it is not possible to prepare a transaction for a private key you don't own if you need to estimate the gasLimit. Code SnippetNo response Contract ABINo response Errorscannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (reason="execution reverted: 8", method="estimateGas", transaction={"......... EnvironmentAltcoin - Please specify (e.g. Polygon) Environment (Other)Polygon Mumbai |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you use a VoidSigner, you can call a contract from a specific account, for example You can also specify Let me know if that helps. :) |
Beta Was this translation helpful? Give feedback.
If you use a VoidSigner, you can call a contract from a specific account, for example
contract.connect(fromAddress).estimateGas.mint(...). When using
.connectwith a string address, it will automatically create a
VoidSigner` for you.You can also specify
from
in the overrides:contract.estiamteGas.mint(... , { from: fromAddress })
.Let me know if that helps. :)