20,000 USDC
View results
Submission Details
Severity: gas
Valid

<x> += <y> Costs More Gas Than <x> = <x> + <y> For State Variables

Summary the expression += can potentially cost more gas than the expression = + when dealing with state variables. Let's explore why this is the case and how the latter expression can be more gas-efficient.

When you use the += operator on a state variable, Solidity performs an additional read operation to load the current value of the variable before performing the addition. This read operation incurs gas costs due to accessing storage.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.