-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy path0x0ebb614204e47c09b6c3feb9aaecad8ee060e23e-CPAY-CPAY.sol
228 lines (173 loc) · 6.72 KB
/
0x0ebb614204e47c09b6c3feb9aaecad8ee060e23e-CPAY-CPAY.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
pragma solidity 0.4.16;
contract ERC20Interface {
function totalSupply() constant returns (uint256 total);
function balanceOf(address _who) constant returns (uint256 balance);
function transfer(address _to, uint256 _value) returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract CPAYToken is ERC20Interface {
using SafeMath for uint256;
string public name = "CPAY Token";
string public symbol = "CPAY";
uint256 public totalSupply = 90414745;
uint8 public decimals = 0;
address public owner;
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
uint256 public totalPayments;
mapping(address => uint256) public payments;
bool public paused = false;
uint256 reclaimAmount;
event Burn(address indexed burner, uint indexed value);
event Mint(address indexed to, uint256 amount);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event PaymentForTest(address indexed to, uint256 amount);
event WithdrawPaymentForTest(address indexed to, uint256 amount);
event Pause();
event Unpause();
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function CPAYToken() {
owner = msg.sender;
balances[owner] = 90414745;
}
function totalSupply() constant returns (uint256 total) {
return totalSupply;
}
function balanceOf(address _who) constant returns (uint256 balance) {
return balances[_who];
}
function transfer(address _to, uint256 _value) whenNotPaused returns (bool success) {
require(_to != address(0));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) whenNotPaused returns (bool success) {
require(_to != address(0));
var _allowance = allowed[_from][msg.sender];
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) whenNotPaused returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
function increaseApproval (address _spender, uint _addedValue) whenNotPaused returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) whenNotPaused returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function burn(uint _value) returns (bool success)
{
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burn(burner, _value);
return true;
}
function mint(address _to, uint256 _amount) onlyOwner returns (bool success) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(0x0, _to, _amount);
return true;
}
function () payable {
}
function pause() onlyOwner whenNotPaused {
paused = true;
Pause();
}
function unpause() onlyOwner whenPaused {
paused = false;
Unpause();
}
function destroy() onlyOwner {
selfdestruct(owner);
}
function transferOwnership(address newOwner) onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function reclaimToken(ERC20Interface token) external onlyOwner {
reclaimAmount = token.balanceOf(this);
token.transfer(owner, reclaimAmount);
reclaimAmount = 0;
}
function asyncSend(address _to, uint256 _amount) onlyOwner {
payments[_to] = payments[_to].add(_amount);
totalPayments = totalPayments.add(_amount);
PaymentForTest(_to, _amount);
}
function withdrawPayments() {
address payee = msg.sender;
uint256 payment = payments[payee];
require(payment != 0);
require(this.balance >= payment);
totalPayments = totalPayments.sub(payment);
payments[payee] = 0;
payee.transfer(payment);
WithdrawPaymentForTest(msg.sender, payment);
}
function withdrawToAdress(address _to, uint256 _amount) onlyOwner {
require(_to != address(0));
require(this.balance >= _amount);
_to.transfer(_amount);
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}