Skip to content

Conversation

@Aboudjem
Copy link

@Aboudjem Aboudjem commented Jun 8, 2024

Hey 👋

I noticed the recommendation to avoid named return arguments for single returns. While it might seem unnecessary, named returns can actually be more gas-efficient because the compiler skips creating additional local variables. This optimization is documented in various Solidity resources:

https://www.rareskills.io/post/gas-optimization
https://zokyo-auditing-tutorials.gitbook.io/zokyo-gas-savings/tutorials/gas-saving-technique-32-optimal-use-of-named-return-variables-in-solidity

@wilsoncusack
Copy link
Contributor

Thanks! How much gas does this save?

@Aboudjem
Copy link
Author

Thanks! How much gas does this save?

We were able to save ~11gas per call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants