-
In my dapp, I have the following flow:
In all cases, the array ends up having either one or two transactions inside. In the latter case, when the allowance is not sufficient, the second transaction cannot be sent because of this error thrown by ethers:
Now, I know what causes this. I am not waiting for the approval transaction to go through, so the state of the blockchain assumes that the allowance is not sufficient and reverts when attempting to call the "transferFrom" function. I want to bypass this check. Basically, I want to optimistically assume that the approval transaction will go through, and that nothing else will cause the deposit transaction to revert. One way to do it is wrap the contract call in a try/ catch block, but that would mean I have to check the error string, so that when the error is different from the one quoted above, the user is alerted about it. Is there a more elegant way to do this in ethers? Maybe there is an option that I can turn on and disable the "would this transaction revert" check? Note: I am using Infura as the provider. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Nevermind, this is a duplicate of #903. The solution was to pass a hardcoded "gasLimit" to the contract call. |
Beta Was this translation helpful? Give feedback.
-
Update: passing a hardcoded gas limit no longer disables the pre-flight checks now. I'm getting an "Internal JSON-RPC error" error even if with a specific gas limit. @ricmoo - do you know of any recent change in Also, is there some sort of flag we could pass to disable the pre-flight checks? |
Beta Was this translation helpful? Give feedback.
Nevermind, this is a duplicate of #903.
The solution was to pass a hardcoded "gasLimit" to the contract call.