The EggstravaganzaNFT
contract includes a totalSupply
State variable intended to track the number of NFTs minted:
However, during proof-of-code testing, I observed that totalSupply
does not increase at all, even when minting new tokens. This indicates a critical functional bug — either the increment operation is not executing as expected, or the value is never being persisted correctly on-chain.
This behavior directly undermines the reliability of totalSupply
, as it does not reflect even the number of minted tokens, let alone burned ones. This is more severe than my original concern of not decrementing on burns. The metric is fundamentally broken and provides a misleading view of the token collection's circulating supply.
Additionally, if the _mint()
function were to revert or fail silently, totalSupply
could fall out of sync with actual token ownership. Because totalSupply
is manually maintained and not derived from internal mappings or enumerated token sets, it is error-prone and misaligned with the actual contract state.
False Supply Reporting: The totalSupply
always returns zero or a static value regardless of how many tokens are minted or burned. Consumers relying on this data - such as EggHunt games - will receive invalid information.
Severe Trust and Transparency Issues: Users cannot determine how many NFTs exist, damaging transparency. Buyers may overestimate scarcity or miss opportunities due to incorrect supply assumptions.
Incompatibility with Ecosystem Tools: Many external platforms and token standards expect totalSupply()
to reflect the true number of tokens. This bug will break assumptions and integration logic for third-party systems.
Potential Logic Failures in Dependent Contracts: If other contracts or scripts use totalSupply
logic (e.g., fair drops, caps, vesting), they will behave incorrectly — potentially introducing exploitable paths elsewhere.
Manual Review
Fix the Incrementation Bug in mintEgg
: Confirm that the line totalSupply += 1;
is being executed as expected. If compiler optimizations or code overrides interfere, consider making the update within a _beforeTokenTransfer()
hook to ensure it executes on successful mints only.
Use a Mappings-Based Approach or ERC721Enumerable
: Implement a reliable token count by deriving the supply from the number of valid token IDs or owners. The ERC721Enumerable
extension from OpenZeppelin is a well-tested solution that tracks total supply, token indices, and ownership.
Update totalSupply
on Burn: If manual tracking continues to be used, _burn()
must be overridden to decrement totalSupply
. Without this, the metric will become inaccurate over time.
Emit Events for Mint/Burn: Emitting Minted
and Burned
events with total supply snapshots can help off-chain indexers recover from inconsistencies.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.