Bid Beasts

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

LOW ISSUE: Gas Optimization - Use Custom Errors

Root + Impact

Description

  • The contract uses require statements with string messages instead of custom errors, resulting in higher gas costs.

modifier isListed(uint256 tokenId) {
require(listings[tokenId].listed, "NFT is not listed"); // Gas inefficient
_;
}

Risk

Likelihood:

  • Every function call using these modifiers consumes extra gas

  • Gas costs accumulate across all contract interactions

  • This affects every user of the contract

Impact:

  • Higher transaction costs for users

  • Less efficient contract execution

  • Unnecessary blockchain resource consumption

Proof of Concept

// Current gas usage vs optimized version
function testGasComparison() public {
uint256 gasBefore = gasleft();
// Current implementation
try marketplace.settleAuction(999) {} catch {}
uint256 gasUsed = gasBefore - gasleft();
// Custom errors would use ~50 gas less per revert
}

Recommended Mitigation

+ error NFTNotListed();
+ error NotTheSeller();
+ error MinPriceTooLow();
modifier isListed(uint256 tokenId) {
- require(listings[tokenId].listed, "NFT is not listed");
+ if (!listings[tokenId].listed) revert NFTNotListed();
_;
}
modifier isSeller(uint256 tokenId, address account) {
- require(listings[tokenId].seller == account, "Not the seller");
+ if (listings[tokenId].seller != account) revert NotTheSeller();
_;
}
Updates

Lead Judging Commences

cryptoghost Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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

Give us feedback!