Level 9 - King ⏺⏺⏺
Level Setup
Level Contract
Exploit
The old king is sent back msg.value before the new king is set. So if the old king is a contract that doesn't implement a receive or fallback function then the call will fail and a new king can't be set, breaking the game.
Create an exploit contract that doesn't contain a
receiveorfallbackfunction.
Submit instance... 🥳
Completion Message
Notes
Executing everything in the constructor removes points of failure e.g. if the prize was calculated before sending, then the transaction was pending for a few blocks, it would no longer be the correct value. So it's better to calculate as much as possible on chain, even if it costs more gas that off-chain calculations, as it's more important that it actually goes through (and the check can be right at the start to minimize wasted gas if it does revert)
Last updated