-
Notifications
You must be signed in to change notification settings - Fork 175
/
BlockList.sol
29 lines (23 loc) · 873 Bytes
/
BlockList.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
// Copyright (C) 2020 d-xo
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.6.12;
import {ERC20} from "./ERC20.sol";
contract BlockableToken is ERC20 {
// --- Access Control ---
address owner;
modifier auth() { require(msg.sender == owner, "unauthorised"); _; }
// --- BlockList ---
mapping(address => bool) blocked;
function block(address usr) auth public { blocked[usr] = true; }
function allow(address usr) auth public { blocked[usr] = false; }
// --- Init ---
constructor(uint _totalSupply) ERC20(_totalSupply) public {
owner = msg.sender;
}
// --- Token ---
function transferFrom(address src, address dst, uint wad) override public returns (bool) {
require(!blocked[src], "blocked");
require(!blocked[dst], "blocked");
return super.transferFrom(src, dst, wad);
}
}