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

Is there any way to fully type safe the transaction errors in Ethers v5 #4630

Open
mostafa-rio opened this issue Mar 2, 2024 · 0 comments
Open
Assignees
Labels
investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5

Comments

@mostafa-rio
Copy link

Ethers Version

5.7

Search Terms

typescript, ERROR, error handling

Describe the Problem

There is a list of Generic Error Codes in the ethers v5 document. But is there a solid way to make transaction errors returning from the contract ( including the validations returned by solidity modifiers )?
And with the current ethers v5 functionality what is the best practice for error handling?

for example, if you take a look at this error returned from Ethers when calling a contract method, is there any way to properly parse this string into an object?

Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (reason="execution reverted: You don't have any reward", method="estimateGas", transaction={"from":"0xCc2edaEdebEA9c37d3aBc3912fF99b08904B1c99","to":"0x29286507623957749A2FC39Cb88393a6EdF4ADDD","data":"0xb88a802f","accessList":null}, error={"code":-32603,"message":"Internal JSON-RPC error.","data":{"code":3,"message":"execution reverted: You don't have any reward","data":"0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000019596f7520646f6e2774206861766520616e792072657761726400000000000000","cause":null}}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.7.2)

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

@mostafa-rio mostafa-rio added investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5 labels Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5
Projects
None yet
Development

No branches or pull requests

2 participants