Contract simulation error, but transaction goes fine #859
Replies: 7 comments 2 replies
-
Does the same happen with another RPC? |
Beta Was this translation helpful? Give feedback.
-
Just tried with ![]() |
Beta Was this translation helpful? Give feedback.
-
Interesting. Looks like that error is definitely coming from the contract, but I wonder what is triggering it. May you share the contract source so I can take a look? Another thing to try: can you add your const { request } = await mainContract.simulate.depositERC([
amountUnit,
currency.contract as `0x${string}`,
currency.contractId,
BigInt(userId)
+], { account }) |
Beta Was this translation helpful? Give feedback.
-
I can share the contract source with you privately if that's ok, otherwise need to ask some permissions (is from my client). But, passing the account make the simulation works. The strange part is that we have a Is there a way to pass the account when creating the contract instance (something like we do for wallet clients)? Thank you so much. |
Beta Was this translation helpful? Give feedback.
-
Could make sense for |
Beta Was this translation helpful? Give feedback.
-
I was having a similar issue using simulate. The error was "Arithmic operation resulted in underflow or overflow." Fixed adding account as options in the simulate function. |
Beta Was this translation helpful? Give feedback.
-
@jxom, recently, I encountered the same issue, but I'm using wagmi version 1.4.12 and viem 1.19.11. The code worked well before. Do you have any idea about it? |
Beta Was this translation helpful? Give feedback.
-
Is there an existing issue for this?
Package Version
1.2.9
Current Behavior
Sorry that I couldn't provide a fully working example as of right now.
I don't have that much experience with Solidity either, and I can't disclosure my full contract source because is from a client, so I can't even use the ABI on StackBlitz.
So, we refactor our dApp to use Viem, which went great! We're just having issue with a function that when I try to simulate, I'm getting:
ContractFunctionExecutionError: The contract function "depositERC" reverted with the following reason: SafeERC20: low-level call failed
I have checked all parameters, types, and even against our previous implementation with Ethers, and it all seems fine.
The strange part is that if I skip the simulation and go direct to write, the transaction goes just fine.
Here's the deployed contract from my client:
https://etherscan.io/address/0x48EAE4259EC1498Cc9092732EdC6e829611d42C3
And this is one of the transaction that simulation said it will be reverted, but it went fine:
https://etherscan.io/tx/0x40df85e3f68770717ce919e30e6f428d6de4a3c52c38ada4df1d5cd04ffa5341
I know that I'm asking maybe too much and giving so little details, it's more a way to check with you guys if this can be something on the library itself, or should I fault my clients contract.
We're writing directly to the contract for now just to avoid this error.
Thanks!
Expected Behavior
No response
Steps To Reproduce
Here some snippers from our code:
Here are some snippets from my client's contract:
Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)
No response
Anything else?
No response
Beta Was this translation helpful? Give feedback.
All reactions