Created
August 5, 2018 14:06
-
-
Save michielmulders/11d1e7cf40774c6237bd278415f1f54b to your computer and use it in GitHub Desktop.
Circuit Breaker Solidity Ethereum smart contract example
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
bool private stopped = false; | |
address private owner; | |
modifier isAdmin() { | |
if(msg.sender != owner) { | |
throw; | |
} | |
_ | |
} | |
function toggleContractActive() isAdmin public | |
{ | |
// You can add an additional modifier that restricts stopping a contract to be based on another action, such as a vote of users | |
stopped = !stopped; | |
} | |
modifier stopInEmergency { if (!stopped) _ } | |
modifier onlyInEmergency { if (stopped) _ } | |
function deposit() stopInEmergency public | |
{ | |
// some code | |
} | |
function withdraw() onlyInEmergency public | |
{ | |
// some code | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment