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

use custom errors to save gas? #39

Open
ipatka opened this issue Jan 11, 2022 · 4 comments
Open

use custom errors to save gas? #39

ipatka opened this issue Jan 11, 2022 · 4 comments

Comments

@ipatka
Copy link
Contributor

ipatka commented Jan 11, 2022

https://blog.soliditylang.org/2021/04/21/custom-errors/

Basically just replace require statement with revert statements

@ameensol
Copy link

do wallets know to warn you if a tx will hit a revert? the same way they do for requires: "this transaction will result in an exception"

@ipatka
Copy link
Contributor Author

ipatka commented Jan 22, 2022

The wallet warning seems to work and etherscan decodes the custom error ABI

Test with require

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
execution reverted: Not gonna work { "originalError": { "code": 3, "data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000e4e6f7420676f6e6e6120776f726b000000000000000000000000000000000000", "message": "execution reverted: Not gonna work" } }

Require: https://rinkeby.etherscan.io/tx/0xdbb38c3d988c8673a44981f0e28e7b1a24ba5a92c93569fee61f411f14ff3813

Test with revert [Custom Error]

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
execution reverted { "originalError": { "code": 3, "data": "0xcaadeb20000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000974dd52cf76a8ca06dcd7ac46dfb6866bdcbe728", "message": "execution reverted" } }

Revert: https://rinkeby.etherscan.io/tx/0x9b4f3bee59a513015463d3b3908cd2469c0934e2396baf920adfa37f19a80862

@ipatka
Copy link
Contributor Author

ipatka commented Jan 22, 2022

Screen Shot 2022-01-22 at 6 38 43 PM

@ameensol
Copy link

lgtm

dekanbro added a commit that referenced this issue Jul 13, 2022
add loot and share singleton to factory constructor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@ameensol @ipatka and others