Use calldata
instead of memory
for external functions where the function argument is read-only.
#29
Labels
bug
Something isn't working
G (Gas Optimization)
resolved
Finding has been patched by sponsor (sponsor pls link to PR containing fix)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
Dravee
Vulnerability details
Impact
On external functions, when using the
memory
keyword with a function argument, what's happening is that amemory
acts as an intermediate.Reading directly from
calldata
usingcalldataload
instead of going viamemory
saves the gas from the intermediate memory operations that carry the values.As an extract from https://ethereum.stackexchange.com/questions/74442/when-should-i-use-calldata-and-when-should-i-use-memory :
Proof of Concept
Tools Used
VS Code
Recommended Mitigation Steps
Use
calldata
instead ofmemory
for external functions where the function argument is read-only.The text was updated successfully, but these errors were encountered: