web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

EIP-838 Error Codes

Open TomiOhl opened this issue 3 years ago • 17 comments

Expected behavior

It would be nice to be able to get the new, custom error codes with their arguments, introduced in Solidity 0.8.4. Ethers.js already supports them: https://github.com/shapeshift/ethers.js/blob/master/packages/tests/src.ts/test-contract-interface.ts#L636

Actual behavior

If I try to catch the error as in the link above, I get the following error message:
Error: Returned error: VM Exception while processing transaction: revert
Error code, error name, etc. are all undefined

Steps to reproduce the behavior

  1. Send a transaction to a contract that will revert with errors
  2. Try to catch the error

Environment

Web3.js v1.5.1 Node v12.18.4 elementary OS 5.1.7

TomiOhl avatar Aug 13 '21 12:08 TomiOhl

This will be addressed in the 4.x rewrite.

philknows avatar Aug 31 '21 18:08 philknows

@philknows Is there a timeline for that? :slightly_smiling_face:

frangio avatar Sep 02 '21 15:09 frangio

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Nov 02 '21 00:11 github-actions[bot]

Still important. OpenZeppelin Contracts is blocked from adopting custom errors until Web3.js supports them.

frangio avatar Nov 02 '21 20:11 frangio

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Jan 15 '22 00:01 github-actions[bot]

Not stale! Waiting patiently. 😁

frangio avatar Jan 15 '22 03:01 frangio

@philknows Is there a timeline for that? slightly_smiling_face

Seems like they plan to release version 4.x in April: RELEASE.md#long-term-support-lts

TomiOhl avatar Feb 08 '22 18:02 TomiOhl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Apr 10 '22 00:04 github-actions[bot]

gm. Dear bot remove the stale label. 😃

TomiOhl avatar Apr 10 '22 10:04 TomiOhl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Jun 10 '22 00:06 github-actions[bot]

@TomiOhl is this issue still active

AyoAlfonso avatar Jun 19 '22 23:06 AyoAlfonso

Yes, it very much is.Haven't tried the one on the 4.x branch yet, but it isn't addressed in the latest 1.x release afaik

TomiOhl avatar Jun 19 '22 23:06 TomiOhl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Aug 19 '22 00:08 github-actions[bot]

Well, 4.x definitely wasn't released in April. Waiting

TomiOhl avatar Aug 19 '22 10:08 TomiOhl

Hey @TomiOhl, we recently released 4.x Alpha last week. Still working diligently now on our Beta release for later this year.

mconnelly8 avatar Aug 30 '22 16:08 mconnelly8

Please @Muhammad-Altabba 🙏🙏🙏

CruzMolina avatar Sep 02 '22 21:09 CruzMolina

Sorry I got busy with other tasks and was also sick for a couple of days :smiling_face_with_tear: . However, I will start working on it very soon :blush:... And nice to see you here @CruzMolina :bouquet:

Muhammad-Altabba avatar Sep 08 '22 18:09 Muhammad-Altabba

Any progress on this? Just deployed a set of contracts in mumbai & polygon using 100% custom errors, and when a transaction fails I can only see "Fail". These opaque error messages makes the debugging process harder and slower. Any alternative or advice please?

DinizSa avatar Apr 26 '23 17:04 DinizSa

Any progress on this? Just deployed a set of contracts in mumbai & polygon using 100% custom errors, and when a transaction fails I can only see "Fail". These opaque error messages makes the debugging process harder and slower. Any alternative or advice please?

  • wait and eventually web3.js 4.0 will be released with support for these custom errors (rc 1 was released last week)
  • or switch to something else:
    • for any other use case than smart contract tests, use ethers.js
    • if you're using web3.js because of truffle, switch to hardhat or foundry/forge
    • if you're using truffle and don't want to switch, use this helper package: https://www.npmjs.com/package/custom-error-test-helper

TomiOhl avatar Apr 26 '23 17:04 TomiOhl