Before doing a transaction, I am trying to use "callStatic" to simulate a transaction/call in order to check if the transaction/call will revert, and if yes- grab the Revert reason to display to the user.
const tempOverride = { value: ethers.utils.parseEther(value) }
await writeContract.callStatic[methodName](...methodParams, tempOverride)
If I have a payable function, and I attempt to try callStatic with my method name, params and the override with my value, I get the following error:
Error: Error: call cannot override value
at ethers.umd.js:9394
at Array.forEach (<anonymous>)
at ethers.umd.js:9392
at async sendTx (sendTx.ts:34)
at async handleRunMethod (Reducer.tsx:235)
instrument.ts:129 Tx will revert. Message: undefined
Am I wrong in thinking I should be able to use callStatic with a value on a payable function? This might be related to my other issue:
Yes, you are correct. I will relax this check too. I'm looking at that function in general and contemplating a larger refactor overall...
I'll look into this now too. :)
This should be fixed now in 5.0.0-beta.189. The Contract has been fairly refactored and should allow value for calls.
Please try it out and let me know if you have any further issue. Thanks! :)
edit: part of the response was for another similar issue and I didn't read close enough which I was responding to; I've updated the above explanation.
Seems to work! Thank you!
Most helpful comment
Seems to work! Thank you!