Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simulateContract does not return revertReason #3067

Closed
1 task done
zamrokk opened this issue Nov 26, 2024 · 2 comments
Closed
1 task done

simulateContract does not return revertReason #3067

zamrokk opened this issue Nov 26, 2024 · 2 comments
Labels
needs reproduction Misc: Needs Reproduction

Comments

@zamrokk
Copy link

zamrokk commented Nov 26, 2024

Check existing issues

Viem Version

2.21.49

Current Behavior

If I send this kind of transaction without passing any ETH on the value, but the deployed Solidity contract will check if the user has sent money, then I receive this error

Execution reverted for an unknown reason

Example of call :

 const { request } = await publicClient!.simulateContract({
          account: walletClient?.account!,
          address: CONTRACT_ADDRESS,
          abi,
          functionName: "bet",
          args: [option, parseEther(amount.toString())],
          
        });
  • if I pass the value => no error , obviously the tx is correct
  • if I call writeContract directly => then I can see the revertReason on the failed tx on BlockScout explorer

I parsed the full error from the try catch, the typeof gives : ContractFunctionExecutionError
There is no revertReason on it ...

I was expecting more a type of ContractFunctionRevertedError instead

Maybe the type cast made by viem is wrong and so, the revertReason data is lost

Expected Behavior

a ContractFunctionRevertedError object with a revertReason

Steps To Reproduce

simulate a tx with money to a contract endpoint that will use require to check that ETH have been sent
Look at the returned error and check all fields, there is no revertReason on it

Link to Minimal Reproducible Example

No response

Anything else?

No response

@jxom
Copy link
Member

jxom commented Nov 26, 2024

Please provide a minimal reproduction.

@jxom jxom added the needs reproduction Misc: Needs Reproduction label Nov 26, 2024
Copy link
Contributor

Hello @zamrokk.

Please provide a minimal reproduction using StackBlitz, TypeScript Playground (for type issues), or a separate minimal GitHub repository.

Minimal reproductions are required as they save us a lot of time reproducing your config/environment and issue, and allow us to help you faster.

Once a minimal reproduction is added, a team member will confirm it works, then re-open the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction Misc: Needs Reproduction
Projects
None yet
Development

No branches or pull requests

2 participants