Created
June 22, 2016 04:43
-
-
Save PeterBorah/4704b62310a31dbf1bed273c98c40fdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract TokenWithEStop { | |
mapping(address => uint) public balanceOf; | |
address public curator; | |
bool public stopped; | |
uint public totalSupply; | |
modifier stopInEmergency { if (!stopped) _ } | |
modifier onlyInEmergency { if (stopped) _ } | |
function TokenWithEStop(address _curator) { | |
curator = _curator; | |
} | |
function deposit(uint amount) stopInEmergency { | |
// intentionally vulnerable | |
balanceOf[msg.sender] += amount; | |
totalSupply += amount; | |
} | |
function transfer(address to, uint value) stopInEmergency { | |
if (balanceOf[msg.sender] >= value) { | |
balanceOf[to] += value; | |
balanceOf[msg.sender] -= value; | |
} | |
} | |
function emergencyStop() { | |
if (msg.sender == curator) { | |
stopped = true; | |
} | |
} | |
function withdraw() onlyInEmergency{ | |
uint balance = balanceOf[msg.sender]; | |
balanceOf[msg.sender] = 0; | |
totalSupply -= balance; | |
if(!msg.sender.send(balance)) throw; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment