Bid Beasts

First Flight #49
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

State Variable Could Be Immutable

Description

  • State variables that are only set once in the constructor should be declared as immutable to optimize gas usage.

  • The BidBeastsNFTMarketPlace::BBERC721 state variable is only set in the constructor but is not marked as immutable, missing a gas optimization opportunity.

@> BidBeasts public BBERC721;

Risk

Likelihood:

  • Affects every deployment and interaction with the contract

  • Consistent gas inefficiency across all operations

Impact:

  • Higher gas costs for contract deployment and state access

  • Missed optimization opportunity

Proof of Concept

function test_LOW_L7_StateVariableCouldBeImmutable() public {
// The BBERC721 state variable is only set once in constructor
address nftAddress = address(market.BBERC721());
assertEq(nftAddress, address(nft), "NFT address should match");
// Deploy another market to verify address is set only once
vm.prank(OWNER);
BidBeasts newNft = new BidBeasts();
BidBeastsNFTMarket newMarket = new BidBeastsNFTMarket(address(newNft));
assertEq(address(newMarket.BBERC721()), address(newNft), "New market should have new NFT");
assertNotEq(address(newMarket.BBERC721()), address(nft), "Should be different addresses");
}

Recommended Mitigation

- BidBeasts public BBERC721;
+ BidBeasts public immutable BBERC721;
Updates

Lead Judging Commences

cryptoghost Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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