Bid Beasts

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

Token ID Starts at Zero inside the `BidBeasts_NFT_ERC721::mint` function

Description

  • NFT token IDs typically start from 1 to avoid confusion with default/uninitialized values in mappings and arrays.

  • The contract starts token IDs from 0, which can cause issues when token ID 0 is used as a default value to represent "no token" in other parts of the system or integrating contracts.

function mint(address to) public onlyOwner returns (uint256) {
@> uint256 _tokenId = CurrenTokenID;
_safeMint(to, _tokenId);
emit BidBeastsMinted(to, _tokenId);
@> CurrenTokenID++;
return _tokenId;
}

Risk

Likelihood:

  • Every first minted NFT will have token ID 0

  • Integration issues occur when other systems assume 0 means "no token"

Impact:

  • Potential confusion in marketplace integrations where 0 typically means "no token"

  • Harder debugging when dealing with default values

Proof of Concept

function test_MEDIUM_TokenIdStartsAtZero() public {
vm.prank(OWNER);
uint256 firstTokenId = nft.mint(ALICE);
// First token ID is 0, which can be problematic
assertEq(firstTokenId, 0, "First token ID should be 0");
assertEq(nft.ownerOf(0), ALICE, "Token ID 0 should be owned by Alice");
}

Recommended Mitigation

- uint256 public CurrenTokenID;
+ uint256 public CurrenTokenID = 1;
Updates

Lead Judging Commences

cryptoghost Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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