pragma solidity ^0.5.0;
contract TestOverflow {
function addOne(uint256 a) public pure returns(uint256) {
require(a + 1 > a, "sorry, a is too big");
return a + 1;
}
}
Compile the code with the button in the Compile tab (or typing control-s)
Deploy the code with the button the the Run tab (it deploys it to a test EVM in your browser by default)
See your new contract in the Deployed Contracts section of Run tab: "TestOverflow at 0x..."
Expand the TestOverflow contract
Enter values in the addOne field and press the addOne label to trigger a transaction to your contract
Observe the output in the console
What value do you need to enter to get it to overflow?
Try using Solidity 0.8+ and observe the change in overflow behaviour