The redeemMemorabilia() function should allow minting NFTs from item ID 1 up to the collection's maximum supply limit, enabling all promised NFTs in a collection to be minted.
An off-by-one error in the supply validation logic prevents the final NFT in each collection from being minted, causing direct economic loss to the protocol.
Likelihood:
Every collection will lose exactly one NFT mint when the currentItemId reaches the maxSupply value
Users attempting to mint the final item in any collection will encounter a "Collection sold out" error despite available supply
Impact:
Direct revenue loss of 1 NFT worth of BEAT tokens per collection (50 BEAT tokens per collection)
User confusion and support burden when collections appear sold out prematurely
Potential regulatory issues from undelivered digital assets advertised as available
This test simulates the minting process for a newly created collection with a maxSupply of 3. We expect the collection to allow three NFTs to be minted successfully.
The test uses three separate user addresses to redeem memorabilia one by one:
The first and second users can successfully mint items with currentItemId values of 1 and 2, respectively.
However, the third user fails to mint, even though the maximum supply hasn’t been reached.
This is due to the condition in the redeemMemorabilia() function:
require(collection.currentItemId < collection.maxSupply, "Collection sold out");
Here, currentItemId starts at 1. So when the third mint is attempted, currentItemId equals maxSupply (3), causing the condition to fail (3 < 3 is false).
As a result, only 2 items can ever be minted for a collection with a maxSupply of 3 — one less than intended. This clearly shows the off-by-one error, which prevents the full utilization of the collection's configured supply.
The final assertEq confirms this by checking that only 2 NFTs were actually minted.
Change the boundary condition to use <= instead of <. This allows currentItemId values from 1 through maxSupply inclusive, enabling all promised NFTs to be minted:
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.