question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Revert Error response processing

See original GitHub issue

Hi, Trying to handle revert errors on gas estimate on-chain, but documentation does not seem to have anything clear on this. Made a few tests but i don’t have much consistency, maybe we could enhance documentation and/or error handling, or even adding code example ? I even tried to understand ethers error logger from https://github.com/ethers-io/ethers.js/blob/eb432aa1f44ad2cc268d000b266eae9b03db1d17/packages/web/src.ts/index.ts

For example, a Uniswap Router Swap revert with “Too little Received” can be parsed to understand issue. I ended up handling pretty ugly like this :

const potentialError =
    typeof error === 'string'
      ? error.match(regexExtract)
      : typeof error.message === 'string'
      ? error.message.match(regexExtract)
      : typeof error.error?.body === 'string'
      ? JSON.parse(error.error?.body)
      : error.error?.message || "No revert reason found";
      

But a revert for whatever reason (token error ?) looks different in error type :

processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":2052,\"error\":{\"code\":-32000,\"message\":\"execution reverted\"}}\n", error={"code":-32000}, requestBody="{\"method\":\"eth_estimateGas\",\"params\":[{\"type\":\"0x2\",\"from\":\"0xf0000000\",\"to\":\"0x12000000\",\"data\":\"0x0000\"}],\"id\":2052,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="http://192.168.1.3:8545", code=SERVER_ERROR, version=web/5.5.0)

So, am i missing something on ethers error on gas estimate ? Or should we enhance documentation ? Also a simple Typescript type Error would be great to parse.

Thanks !

PS : addresses are fine, just changed them for privacy matters

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ricmoocommented, Mar 25, 2022

I’m working on a fix to help consolidate these. The Hardhat error will be hard to process in its current state, but I’ll make a request for them to format it so it is machine readable (in addition to human-readable).

0reactions
RohitAuditcommented, Aug 19, 2022

Was this error fixed or is it still open?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: VM Exception while processing transaction: revert.
A Guide to Problem-Solving in Solidity.​​ Then there is Error: VM Exception while processing transaction: revert, the most common and frustrating ...
Read more >
Solidity Error Handling with assert(), require(), revert() - Finxter
As a simple guideline: Use the require() function to check conditions on inputs. Use the revert() function with if conditions to raise a...
Read more >
I'm getting this error : VM Exception while processing ...
I'm getting this error : VM Exception while processing transaction: revert, while trying to send value from my frontend to smart contract ;...
Read more >
Solidity - Error Handling - Tutorialspoint
revert(string memory reason) − This method aborts the execution and revert any changes done to the state. It provides an option to provide...
Read more >
Errors and Revert Statements in Solidity - Knoldus Blogs
The error creates data that is then passed to the caller with the revert operation to either return to the off-chain component or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found