The owner can call function setTreatCost(string, uint256)
by passing 0 ether to the _cost
parameter which will break the treat and the cost cannot be changed anymore.
This means the owner can call setTreatCost(string, uint256)
function and set the cost to 0 ether.
After that if the owner tries to change the cost for this treat again it will fails because of the following line of code in the function setTreatCost(string, uint256)
:
This line checks the current cost of the treat to be > 0.
Then users will never be able to mint NFT for this treat, because of the function trickOrTreat(string)
checks if the cost of the treat is > 0.
Another case will be if there are users should pay 2x price of the treat, but did not call the resolveTrick
function yet.
If the cost is changed to 0 between the minting of the NFT and the call to the resolveTrick
function, these users will be able to receive the NFT for a lot cheaper than the other users. (The users which claimed the NFT and paid full or 2x price before changing the cost to 0 ether)
This is because in the resolveTrick
function at the bottom is this code which will refund ETH to the players, so basically the players will pay only gas fee for this NFT.
Specific example:
User BoB tries his chance with the trickOrTreat function to mint NFT. He is unlucky and he has to pay 2x the price, however paid only the gas price since there is no validation about the value of the transaction in case of 2x.
Because of that he paid only gas price and the NFT was minted to the contract.
The owner changes the cost of the treat to 0 by calling setTreatCost function
Bob decides that he wants to get the NFT because he really likes it, so he calls function resolveTrick
Bob receives the NFT for free (only paying gas price twice).
Add the following test to the class TestTrickOrTreat.t.sol (test class is not part of the project so you have to create it):
This makes the treat unusable and also allow certain users(players) to mint the NFT for a lot cheaper than others.
foundry
In the function setTreatCost
check if the parameter _cost > 0
instead of checking the current cost function:
The cost of the treat is set only by the owner (in the constructor, in addTreat and in setTreatCost). That means the cost of the treat will always be greater than zero.
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.