Skip to main content
7 events
when toggle format what by license comment
Oct 20, 2022 at 21:27 vote accept Nat
Oct 20, 2022 at 20:57 answer added Ismael timeline score: 1
Oct 20, 2022 at 16:01 comment added Nat Yes but there is no chance of over/under flow in those 2 lines. The uint256 is checked as it is passed to the function so it cannot over/underflow. So this doesn't explain why it needs to be outside the unchecked statement. To your example, if you're dealing with a uint8 let's say you cannot pass 256 as you will get the error above, nor could you pass the same max for uint256. So you cannot pass the 12 and even if you did it would still assert. Unchecked simply forgoes over/underflow check to save gas.
Oct 20, 2022 at 1:49 comment added Ismael You cannot transfer more than existing balance, so a check is needed. If the existing balance is 10 you cannot transfer 12.
Oct 19, 2022 at 23:52 comment added Nat It can't be invalid because it's passed as a uint256. Try passing an overflow value in remix. You will get "value out-of-bounds" if it's wrapped with unchecked or not.
Oct 19, 2022 at 23:42 comment added Ismael What do you mean with "a check at the mint function"? Usually amount is user supplied so it could be an invalid amount.
Oct 19, 2022 at 16:04 history asked Nat CC BY-SA 4.0