As a challenger, it is possible to participate in battles without putting CredToken
tokens at stake by simply not approving the RapBattle
contract to spend one's tokens. This way, if the battle is lost, the entire transaction will revert.
The code snippet below contains the logic for determining the winner:
Notice that, if the defender wins and the challenger has not approved the RapBattle
contract to spend its CredToken
, the transaction will fail (effectively canceling the battle).
This is considered to be high risk because it defeats the whole purpose of RapBattle
and CredToken
(as indicated in the documentation, it is "The primary currency at risk in a rap battle").
In order to observe the behavior explained above, add the following test to test/OneShotTest.t.sol
:
And run it with forge test -vvvv --mt testChallengerNoRisk
. Observe that when the defender (Alice) is the winner, the test will fail because the challenger (Bob) did not approve RapBattle
to spend enough of his CredToken
tokens.
Manual analysis and Foundry.
Challengers should also be required to send their CredToken
tokens when participating in a battle.
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.