The contract fails to increment the total supply of NFTs with each mint, leading to repeated attempts to mint the same NFT identifier and consequently causing the transaction to revert.
The issue is located in the minting function MINT_HORSE()
within the Huff code. The function, designed to mint a new NFT, references the TOTAL_SUPPLY
but does not increment it after minting an NFT. This oversight results in the TOTAL_SUPPLY
remaining constant, causing every minting attempt after the first to try to mint an NFT with an already existing identifier.
The relevant code from the HorseStore.huff
file is as follows:
This bug effectively renders the contract incapable of minting more than one unique NFT, severely limiting the functionality and utility of the NFT contract. It directly contradicts the expected behavior of an NFT minting process, where each minted token should have a unique identifier.
Manual review
To rectify this problem, the following changes are recommended:
Modify the MINT_HORSE()
function to increment the TOTAL_SUPPLY
each time an NFT is successfully minted. This can be achieved by adding a line of code within the macro to increment the TOTAL_SUPPLY
storage variable.
Ensure that the incrementation logic correctly handles potential overflows to maintain contract security.
After implementing the changes, thoroughly test the updated contract to verify that each minting operation results in a unique NFT identifier and that the TOTAL_SUPPLY
reflects the correct number of minted NFTs.
Sample fix:
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.