September 2019
Beginner to intermediate
540 pages
13h 3m
English
The MyERC20Token contract requires an admin who has the ability to lock or unlock the coins of anyone's account. The pausable contract defines the whenNotPaused and whenPaused modifiers. By checking the paused flag, the smart contract can toggle between the paused and not paused contract state. The following code shows this implementation:
contract Pausable is owned { event PausedEvt(address account); event UnpausedEvt(address account); bool private paused; constructor () internal { paused = false; } modifier whenNotPaused() {require(!paused); _; } modifier whenPaused() {require(paused); _; } function pause() public onlyAdmin whenNotPaused { paused = true; emit PausedEvt(msg.sender); } function unpause() public ...Read now
Unlock full access