You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parameters daMinters, daAmountPaid, daNumMinted and numSold are not necessary to _mint. Therefore gas could be saved in case _mint reverts if _mint was set before such parameters. Check example below.
for (uint256 i = 0; i < numWarriors; i++) {
_mint(msg.sender);
}
daMinters.push(msg.sender);
daAmountPaid[msg.sender] += msg.value;
daNumMinted[msg.sender] += numWarriors;
numSold += numWarriors;
if (numSold == maxDaSupply) {
// optimistic: save gas by not setting on every mint, but will
// require manual `setFinalPrice` before refunds if da falls short
finalPrice = currentPrice;
}
The use of _msgSender when there is no implementation of a meta transaction mechanism that uses it, such as EIP-2771, very slightly increases gas consumption.
I suggest replacing _msgSender with msg.sender if there is no mechanism to support meta-transactions like EIP-2771 implemented.
GAS
G-01:
for
loop gas optimizationForgottenRunesWarriorsMinter.sol#L162
ForgottenRunesWarriorsMinter.sol#L220
ForgottenRunesWarriorsMinter.sol#L259
ForgottenRunesWarriorsMinter.sol#L355
Unnecessary to update uint to default value of zero.
Prefix instead of postfix increments and unchecked increments can save gas.
Taking all changes into account I recommend change a loop like this:
To this:
G-02: Parameters order could save gas on mint fail
ForgottenRunesWarriorsMinter.sol#L163
Parameters
daMinters
,daAmountPaid
,daNumMinted
andnumSold
are not necessary to_mint
. Therefore gas could be saved in case_mint
reverts if_mint
was set before such parameters. Check example below.G-03: No need to use
_msgSender
ForgottenRunesWarriorsGuild.sol#L101
The use of
_msgSender
when there is no implementation of a meta transaction mechanism that uses it, such as EIP-2771, very slightly increases gas consumption.I suggest replacing
_msgSender
withmsg.sender
if there is no mechanism to support meta-transactions like EIP-2771 implemented.G-04: Gas can be saved by shortening syntax
ForgottenRunesWarriorsMinter.sol#L182
Gas could be saved by changing:
To:
G-05: Lore
R
contains very large stringForgottenRunesWarriorsGuild.sol#L33
Having in mind that this might be unnegotiable I suggest shortening Lore
R
to less than 32 bytes to save gas.The text was updated successfully, but these errors were encountered: