Ethernaut Puzzle 05 Token
The goal of this level is for you to hack the basic token contract below.
You are given 20 tokens to start with and you will beat the level if you somehow manage to get your hands on any additional tokens. Preferably a very large amount of tokens.
1 | // SPDX-License-Identifier: MIT |
As it is uint, which means unsigned integer, so it is meaningless to validate uint >= 0, it is always more than 0.
Then the answer is obvious, you can just run this command in your browser console:
1 | contract.transfer({%your wallet address%}, 21) |
Then your balance in this smart contract will be really large because it is overflow.