NFT Dealers

First Flight #58
Beginner FriendlyFoundry
100 EXP
Submission Details
Impact: low
Likelihood: medium

[G-2] Metadata state variables implementation is redundant and can be removed

Author Revealed upon completion

Metadata state variables implementation is redundant and can be removed

Description

The contract implements 3 state variables that can be removed:

  1. string public collectionName: already accessible with the name public function inherited from ERC721.

  2. string public tokenSymbol: already accessible with the symbol public function inherited from ERC721.

  3. bool public metadataFrozen: this variable is declared but never used, it should definitely be removed.

Storing and initializing these variables in the constructor is inflating the creation bytecode size, causing higher deployment gas cost.

@> string public collectionName;
@> string public tokenSymbol;
@> bool public metadataFrozen;

Recommended Mitigation

Delete the 3 state variables:

- string public collectionName;
- string public tokenSymbol;
- bool public metadataFrozen;
constructor(
address _owner,
address _usdc,
string memory _collectionName,
string memory _symbol,
string memory _collectionImage,
uint256 _lockAmount
) ERC721(_collectionName, _symbol) {
owner = _owner;
usdc = IERC20(_usdc);
- collectionName = _collectionName;
- tokenSymbol = _symbol;
collectionImage = _collectionImage;
lockAmount = _lockAmount;
}

Support

FAQs

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

Give us feedback!