State variables only set in the constructor should be declared immutable
Use immutable
if you want to assign a permanent value at construction. Use constant
if you already know the permanent value. Both get directly embedded in bytecode, saving SLOAD
.
Variables only set in the constructor and never edited afterwards should be marked as immutable, as it would avoid the expensive storage-writing operation in the constructor (around 20_000 gas) and replace the expensive storage-reading operations (first time 2_100 gas, every other time 100 gas) to a less expensive value reading (3 gas)
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L67
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/utils/Ownable.sol#L8
Gas savings
Manual review
Set these variables as immutable
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.