-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCUPT.sol
More file actions
189 lines (162 loc) · 5.56 KB
/
CUPT.sol
File metadata and controls
189 lines (162 loc) · 5.56 KB
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract CUPT {
bool public paused;
string public constant name = "CUPT";
string public constant symbol = "CUPT";
uint8 public constant decimals = 6;
uint256 public totalSupply;
address public owner;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
mapping(address => bool) public blacklisted;
mapping(address => bool) public whitelistedContracts;
// Add pause event
event Paused(address account);
event Unpaused(address account);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
event Burn(address indexed from, uint256 value);
event Mint(address indexed to, uint256 value);
event Blacklisted(address indexed account, bool status);
event Whitelisted(address indexed account, bool status);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
// Add whenNotPaused modifier
modifier whenNotPaused() {
require(!paused, "Contract is paused");
_;
}
// Add whenPaused modifier
modifier whenPaused() {
require(paused, "Contract is not paused");
_;
}
constructor() {
owner = msg.sender;
totalSupply = 3750000000 * 10 ** 6;
balanceOf[msg.sender] = totalSupply;
paused = false; // Initialize as unpaused
}
// Add pause/unpause functions
function pause() external onlyOwner whenNotPaused {
paused = true;
emit Paused(msg.sender);
}
function unpause() external onlyOwner whenPaused {
paused = false;
emit Unpaused(msg.sender);
}
modifier notBlacklisted(address account) {
require(!blacklisted[account], "Account is blacklisted");
_;
}
function blacklist(address account, bool status) external onlyOwner {
require(blacklisted[account] != status, "Already in this state");
blacklisted[account] = status;
emit Blacklisted(account, status);
}
function isWhitelisted(address _contract) external view returns (bool) {
return whitelistedContracts[_contract];
}
function addToWhitelist(address _contract) external onlyOwner {
require(isContract(_contract), "Not a contract");
whitelistedContracts[_contract] = true;
emit Whitelisted(_contract, true);
}
function removeFromWhitelist(address _contract) external onlyOwner {
require(whitelistedContracts[_contract], "Not in whitelist");
whitelistedContracts[_contract] = false;
emit Whitelisted(_contract, false);
}
function transfer(
address to,
uint256 value
)
public
whenNotPaused
notBlacklisted(msg.sender)
notBlacklisted(to)
returns (bool)
{
uint256 senderBalance = balanceOf[msg.sender];
require(to != address(0), "Cannot transfer to zero address");
require(senderBalance >= value, "Insufficient balance");
senderBalance -= value;
balanceOf[msg.sender] = senderBalance;
balanceOf[to] += value;
emit Transfer(msg.sender, to, value);
return true;
}
function approve(
address spender,
uint256 value
) public whenNotPaused returns (bool) {
require(spender != address(0), "Cannot approve zero address");
require(
value == 0 || allowance[msg.sender][spender] == 0,
"Reset allowance to zero first"
);
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function transferFrom(
address from,
address to,
uint256 value
)
public
whenNotPaused
notBlacklisted(from)
notBlacklisted(to)
returns (bool)
{
require(to != address(0), "Cannot transfer to zero address");
require(balanceOf[from] >= value, "Insufficient balance");
require(allowance[from][msg.sender] >= value, "Allowance exceeded");
balanceOf[from] -= value;
balanceOf[to] += value;
allowance[from][msg.sender] -= value;
emit Transfer(from, to, value);
return true;
}
function mint(address to, uint256 amount) external onlyOwner whenNotPaused {
require(to != address(0), "Cannot mint to zero address");
require(amount > 0, "Amount must be positive");
totalSupply += amount;
balanceOf[to] += amount;
emit Mint(to, amount);
}
function burn(uint256 amount) external whenNotPaused {
require(amount > 0, "Amount must be positive");
require(balanceOf[msg.sender] >= amount, "Insufficient balance");
totalSupply -= amount;
balanceOf[msg.sender] -= amount;
emit Burn(msg.sender, amount);
}
// Add these to your current token contract
// To support future staking/LP features
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "New owner is zero address");
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}