Ethers.js: Add Solidity Custom Error support to Interface

Created on 22 Apr 2021  路  7Comments  路  Source: ethers-io/ethers.js

Solidity has announced and released EIP-838 support for user defined errors in Solidity, so I will be adding support to human-readable ABI, the ABI fragment parser and the Interface in the next minor bump.

enhancement fixed minor-bump

Most helpful comment

Other Useful Links:

I have this working locally, but have a few other changes I want to roll into this minor bump.

All 7 comments

Other Useful Links:

I have this working locally, but have a few other changes I want to roll into this minor bump.

Please note that Solidity does not implement EIP-838. That proposed RLP encoding and some prefix, and I can't remember what else was discussed there. Please do not include EIP-838 in the documentation, as that would be misleading users.

The encoding specification is here: https://docs.soliditylang.org/en/v0.8.4/abi-spec.html#errors

@axic The only mention of RLP in the above EIP-838 spec seems to be a typo, which should have read ABI, no?

Any arguments for the error are RLP encoded in the same way as return values from functions.

Function outputs are ABI encoded, not RLP encoded...

It also says the following:

The exact format in which both the selector and the arguments are encoded is to be defined. The Solidity implementation mentioned above leaves room for expansion by prefixing the free-form string with uint256(0).

And that EIP was initially for the reason string, which has been supported in Solidity for quite a bit (revert("string") or require(x, "string")).

I see now that @chriseth commented there, which may be the reason for this confusion 馃槄

Anyway please just link to the Solidity documentation (and follow the description there), as that discussion never materialised as an EIP.

Sounds good to me. And I'll stop using the phrase EIP-838 starting... now. :)

Also note, that "Error(string)"has been supported in ethers since it existed, and the changes to fully support the error strings were fairly minor. I've got about 12 features I'm trying to roll into this minor release and am on the last one now, so full support should be out soon. :)

Nice!

And thanks for taking the above into consideration, my aim is to avoid potential confusion as that could mean more work for both of us 馃槄 I wish everything was properly standardised/documented under EIPs, but the process is tedious and was blocked on certain issues regarding the ABI so far.

@axic, @chriseth implied that Solidity had implemented EIP838 in https://github.com/ethereum/EIPs/issues/838#issuecomment-824717043. Would you mind posting a comment over there explaining that it's not the case?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jochenonline picture jochenonline  路  3Comments

dave-dm picture dave-dm  路  3Comments

rekmarks picture rekmarks  路  3Comments

crazyrabbitLTC picture crazyrabbitLTC  路  3Comments

thegostep picture thegostep  路  3Comments