-
|
When calling a contract I am getting an error without any revert reasons: Here is an example: Meanwhile, In the Javascript console I see that the Metamask returns the following JSON RPC error: {
"code": -32603,
"message": "Internal JSON-RPC error.",
"data": {
"code": 3,
"message": "execution reverted",
"data": "0xa2fb840f"
}
}Yes, I can identify an error by iterating through the errors ABI and comparing encoded error selectors (data.message === keccak256("MyCustomError()").substr(0, 10)). But, Is it possible to handle custom solidity errors? If yes, then how. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Yes, it is supported and it should be automatic. We have a test for it here: https://github.com/wagmi-dev/viem/blob/main/src/actions/public/simulateContract.test.ts#L242 Might be something to do with the response structure. Will take a look. Off-topic: I would avoid using |
Beta Was this translation helpful? Give feedback.
I can confirm that using
httptransport for the public client has fixed the issue. Nowcause.data.errorNamereturns a custom error