-
Notifications
You must be signed in to change notification settings - Fork 175
/
Pausable.sol
36 lines (30 loc) · 1.05 KB
/
Pausable.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (C) 2020 d-xo
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.6.12;
import {ERC20} from "./ERC20.sol";
contract PausableToken is ERC20 {
// --- Access Control ---
address owner;
modifier auth() { require(msg.sender == owner, "unauthorised"); _; }
// --- Pause ---
bool live = true;
function stop() auth external { live = false; }
function start() auth external { live = true; }
// --- Init ---
constructor(uint _totalSupply) ERC20(_totalSupply) public {
owner = msg.sender;
}
// --- Token ---
function approve(address usr, uint wad) override public returns (bool) {
require(live, "paused");
return super.approve(usr, wad);
}
function transfer(address dst, uint wad) override public returns (bool) {
require(live, "paused");
return super.transfer(dst, wad);
}
function transferFrom(address src, address dst, uint wad) override public returns (bool) {
require(live, "paused");
return super.transferFrom(src, dst, wad);
}
}