-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRBAC.sol
42 lines (30 loc) · 894 Bytes
/
RBAC.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
37
38
39
40
41
42
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.10;
contract Rbac {
// state variables
address public owner;
mapping (address => uint256) public balances;
mapping (address => bool) public blacklisted;
constructor() public{
owner = msg.sender;
balances[owner] = 1000;
blacklisted[owner] = false;
}
modifier not_blacklisted {
if (blacklisted[owner]){
_;
}
}
modifier at_least(uint256 x) {
if (balances[owner] < x){
_;
}
}
function blacklist() public {
blacklisted[owner] = true;
}
function transfer(address _dest, uint256 _amount) public not_blacklisted at_least(_amount) {
balances[owner] -= _amount;
balances[_dest] += _amount;
}
}