Snowman Merkle Airdrop

AI First Flight #10
Beginner FriendlyFoundrySolidityNFT
EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Unnecessary Explicit Initialization of State Variable to Default Value

Description

In the constructor, the state variable s_TokenCounter (a uint256) is explicitly assigned the value 0:

solidity

s_TokenCounter = 0; // @audit-low- already initialized to 0 no need for this

Solidity automatically initializes all state variables to their default values during contract creation. For uint256, the default value is 0. Therefore, this explicit assignment is redundant.

Risk

This line generates an unnecessary SSTORE operation in the deployed bytecode. Although the storage slot is already 0 (original value = new value = 0), the EVM still incurs gas costs for the operation:

  • A "no-op" SSTORE (setting a slot to its current value) costs approximately 2,100 gas (cold SLOAD access under EIP-2929) plus additional overhead.

  • This increases the contract deployment cost by a few thousand gas without providing any functional benefit.

While the gas impact is minor compared to overall deployment costs, it represents avoidable inefficiency.

Proof of Concept

State variables declared without an initializer are set to 0 before the constructor executes. The assignment in the constructor performs a redundant write to a slot that is already at the target value.

Recommendation Mitigation

Remove the redundant assignment:

solidity

constructor(string memory _SnowmanSvgUri) ERC721("Snowman Airdrop", "SNOWMAN") Ownable(msg.sender) {
- s_TokenCounter = 0;
s_SnowmanSvgUri = _SnowmanSvgUri;
}

This change reduces deployment gas consumption and aligns with Solidity best practices for gas-efficient code.

Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 3 hours ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!