GivingThanks

First Flight #28
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

tokenCounter is already initialized to default value of 0, no need to do this in constructor

Summary

In Solidity, uint256 variables are automatically initialized to 0. Therefore, the explicit assignment tokenCounter = 0 in the constructor is redundant, as the line uint256 public tokenCounter; already ensures a default value of 0. This assignment can be safely removed for cleaner and more efficient code.

Vulnerability Details

tokenCounter is assigned a value of 0 in the constructor which is redundant as the line uint256 public tokenCounter; is already initialized with a default value of 0.

constructor(address _registry) ERC721("DonationReceipt", "DRC") {
registry = CharityRegistry(msg.sender);
owner = msg.sender;
@> tokenCounter = 0;
}

Impact

Removing the redundant tokenCounter = 0 assignment saves a small amount of gas and slightly reduces bytecode size, optimizing contract deployment.

Tools Used

Manual review

Recommendation

Remove this line tokenCounter = 0; in the constructor and update the code as shown below.

constructor(address _registry) ERC721("DonationReceipt", "DRC") {
registry = CharityRegistry(msg.sender);
owner = msg.sender;
}
Updates

Lead Judging Commences

n0kto Lead Judge 12 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.