alchemy-web3 icon indicating copy to clipboard operation
alchemy-web3 copied to clipboard

Revert reason is not returned while it shows on Alchemy dashboard

Open laygir opened this issue 4 years ago • 2 comments

Hello,

I'm trying to get the revert reason of a transaction on my frontend. When using Alchemy I get the error on the screenshot and notice there is no revert reason. But on the Alchemy dashboard, I can see the revert reason speed invalid as expected.

image

image

Here's the repo for a reproduction case, just add your api key and give it a shot. https://github.com/laygir/web3-revert-test/tree/using-alchemy

Following contract is being used for this reproduction case.

contract CallRevert {
    uint256 speed;

    function Start(uint256 _speedPercent) public {
        require(_speedPercent <= 100, 'speed invalid');
        speed = _speedPercent;
    }
}

When deployed and a transaction sent locally againts Hardhat, here's the result.

image

*I've tried getting help on Discord but no luck, so creating an issue here.

laygir avatar Feb 25 '22 09:02 laygir

@laygir I dug into this some more, and the error reason is being dropped in the web3.js library.

In utils._fireError, the error string is being created without error.reason which contains the speed invalid error we hit in the contract (link).

Unfortunately, there's not much we can do here since we wrap web3. Happy to update the web3 dependency if web3.js comes out with a fix for the error. I'll leave this issue open in the meantime.

thebrianchen avatar Mar 15 '22 00:03 thebrianchen

Hey @thebrianchen Thank you for taking the time for it, really appreciate it! 🙏

Do you know how Alchemy dashboard handles this and able to display user friendly message on the dashboard?

Meanwhile just to create awareness, I also have an issue open on ChainSafe side, perhaps your finding could help anybody out there who could make a PR on this.

https://github.com/ChainSafe/web3.js/issues/4787

laygir avatar Mar 15 '22 14:03 laygir