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

⚡️ payable expansion #1030

Open
z0r0z opened this issue Jul 31, 2024 · 1 comment
Open

⚡️ payable expansion #1030

z0r0z opened this issue Jul 31, 2024 · 1 comment

Comments

@z0r0z
Copy link
Collaborator

z0r0z commented Jul 31, 2024

The Solidity payable modifier essentially puts function calls into their default state without extra security checks for rejecting msg.value. Saving a small amount of gas.

This Solady issue is raised to explore the preference of making most Solady functions payable by default and encouraging end-users to inherit and override with a check (require(msg.value == 0) to enforce Solidity's high-level security behavior.

The potential benefits here go beyond gas savings. Users will also have the choice to integrate payable behaviors into their Solady contracts. For example, a protocol might enforce an ether tax on transferring tokens. Currently this is not something they can do.

The obvious drawback is that there is an immediate footgun in that shoddy UIs and Solady developers who do not add custom security checks might expose users to unexpected function call payments.

So let's explore further.

Screenshot 2024-07-31 at 2 45 38 PM
@0xCLARITY
Copy link

Might impact the gas savings a little - but you could imagine the Solady libraries having functions like:

    function isFunctionXPayable() internal view virtual;

and then in your implementation you do:

    // default non-payable implementation
    function isFunctionXPayable() internal override {
        if (msg.value > 0) revert NotPayable();
    }
    
    // Or you want a payable function and do this:
    function isFunctionXPayable() internal override {}

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

2 participants