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

AbiCoder: decode revert errors #596

Open
sohkai opened this issue Sep 1, 2019 · 2 comments

Comments

@sohkai
Copy link

commented Sep 1, 2019

Related to #368, ethereum/web3.js#1707.

Even though transaction receipts do not give us revert error strings, eth_calls do, and it would be nice if the AbiCoder knew how to decode them (and likely, throw an error with the string).

In particular, there was a situation where I wanted to query a contract for boolean value. Some times, this check reverts (perhaps the contract is not completely done being set up yet), but ethers' AbiCoder takes the 0x08c379a0...<revert string> result from the eth_call and says, yes, that's a boolean (and a true one at that!).

@ricmoo

This comment has been minimized.

Copy link
Member

commented Sep 1, 2019

This shouldn’t be handled by the ABI library, but by the Contract library (which performs the eth_call). The ABI library cannot know what the underlying data represents. The result of the call will be a bytes of length congruent to 4 mod 32, and the ABI coder doesn’t work with signature prefixed data.

Is the contract using the standard “Error(string)” for its revert? If so, you should have got a CALL_REVERT error with the error message already parsed. How are you calling the contract?

@ricmoo ricmoo added the discussion label Sep 1, 2019

@sohkai

This comment has been minimized.

Copy link
Author

commented Sep 2, 2019

Is the contract using the standard “Error(string)” for its revert?

Yes.

If so, you should have got a CALL_REVERT error with the error message already parsed. How are you calling the contract?

I'm using web3@1.2.1, so then the problem may lie there. web3's contract module just passes the output data into ethers' AbiCoder for output, but perhaps it should first detect and decode these errors before trying to abi decode the output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.