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

eth contract: replace error with other var names #219

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

ppca
Copy link
Contributor

@ppca ppca commented Feb 13, 2025

error (Special Solidity Feature)

Introduced in Solidity 0.8.4.
Allows defining custom errors that can be used with revert, making reverts more gas-efficient compared to require with string messages.
Example:

error Unauthorized(address user);

function restrictedFunction() public {
    if (msg.sender != owner) {
        revert Unauthorized(msg.sender);
    }
}

Using error is cheaper than reverting with a string message because it avoids storing large strings in transaction logs.

We should not use error as variable name

@ppca ppca requested a review from volovyks February 13, 2025 18:50
@volovyks volovyks merged commit 349927e into develop Feb 13, 2025
2 of 3 checks passed
@volovyks volovyks deleted the xiangyi/modify_error branch February 13, 2025 18:54
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

Successfully merging this pull request may close these issues.

2 participants