1
+ pragma solidity ^ 0.5.0 ;
2
+
3
+ /**
4
+ * @dev Wrappers over Solidity's arithmetic operations with added overflow
5
+ * checks.
6
+ *
7
+ * Arithmetic operations in Solidity wrap on overflow. This can easily result
8
+ * in bugs, because programmers usually assume that an overflow raises an
9
+ * error, which is the standard behavior in high level programming languages.
10
+ * `SafeMath` restores this intuition by reverting the transaction when an
11
+ * operation overflows.
12
+ *
13
+ * Using this library instead of the unchecked operations eliminates an entire
14
+ * class of bugs, so it's recommended to use it always.
15
+ */
16
+
17
+ library SafeMath {
18
+ function mul (uint256 a , uint256 b ) internal pure returns (uint256 ) {
19
+ if (a == 0 ) {
20
+ return 0 ;
21
+ }
22
+ uint256 c = a * b;
23
+ assert (c / a == b);
24
+ return c;
25
+ }
26
+
27
+ function div (uint256 a , uint256 b ) internal pure returns (uint256 ) {
28
+ uint256 c = a / b;
29
+ return c;
30
+ }
31
+
32
+ function sub (uint256 a , uint256 b ) internal pure returns (uint256 ) {
33
+ assert (b <= a);
34
+ return a - b;
35
+ }
36
+
37
+ function add (uint256 a , uint256 b ) internal pure returns (uint256 ) {
38
+ uint256 c = a + b;
39
+ assert (c >= a);
40
+ return c;
41
+ }
42
+
43
+ function ceil (uint256 a , uint256 m ) internal pure returns (uint256 ) {
44
+ uint256 c = add (a,m);
45
+ uint256 d = sub (c,1 );
46
+ return mul (div (d,m),m);
47
+ }
48
+ }
49
+
50
+ interface IERC20 {
51
+ function totalSupply () external view returns (uint256 );
52
+ function balanceOf (address who ) external view returns (uint256 );
53
+ function allowance (address owner , address spender ) external view returns (uint256 );
54
+ function transfer (address to , uint256 value ) external returns (bool );
55
+ function approve (address spender , uint256 value ) external returns (bool );
56
+ function transferFrom (address from , address to , uint256 value ) external returns (bool );
57
+
58
+ event Transfer (address indexed from , address indexed to , uint256 value );
59
+ event Approval (address indexed owner , address indexed spender , uint256 value );
60
+ }
61
+ contract ERC20Detailed is IERC20 {
62
+
63
+ string private _name;
64
+ string private _symbol;
65
+ uint8 private _decimals;
66
+
67
+ constructor (string memory name , string memory symbol , uint8 decimals ) public {
68
+ _name = name;
69
+ _symbol = symbol;
70
+ _decimals = decimals;
71
+ }
72
+
73
+ function name () public view returns (string memory ) {
74
+ return _name;
75
+ }
76
+
77
+ function symbol () public view returns (string memory ) {
78
+ return _symbol;
79
+ }
80
+
81
+ function decimals () public view returns (uint8 ) {
82
+ return _decimals;
83
+ }
84
+ }
85
+
86
+ contract WallstreetbetsToken is ERC20Detailed {
87
+
88
+ using SafeMath for uint256 ;
89
+ mapping (address => uint256 ) private _balances;
90
+ mapping (address => mapping (address => uint256 )) private _allowed;
91
+
92
+ string constant tokenName = "Wallstreetbets " ;
93
+ string constant tokenSymbol = "WSB " ;
94
+ uint8 constant tokenDecimals = 18 ;
95
+ uint256 _totalSupply = 1E27 ;
96
+
97
+ constructor () public payable ERC20Detailed (tokenName, tokenSymbol, tokenDecimals) {
98
+ _mint (msg .sender , _totalSupply);
99
+ }
100
+
101
+ function totalSupply () public view returns (uint256 ) {
102
+ return _totalSupply;
103
+ }
104
+
105
+ function balanceOf (address owner ) public view returns (uint256 ) {
106
+ return _balances[owner];
107
+ }
108
+
109
+ function allowance (address owner , address spender ) public view returns (uint256 ) {
110
+ return _allowed[owner][spender];
111
+ }
112
+
113
+ function transfer (address to , uint256 value ) public returns (bool ) {
114
+ require (value <= _balances[msg .sender ]);
115
+ require (to != address (0 ));
116
+
117
+ _balances[msg .sender ] = _balances[msg .sender ].sub (value);
118
+ _balances[to] = _balances[to].add (value);
119
+
120
+ _totalSupply = _totalSupply.sub (value);
121
+
122
+ emit Transfer (msg .sender , to, value);
123
+ return true ;
124
+ }
125
+
126
+ function multiTransfer (address [] memory receivers , uint256 [] memory amounts ) public {
127
+ for (uint256 i = 0 ; i < receivers.length ; i++ ) {
128
+ transfer (receivers[i], amounts[i]);
129
+ }
130
+ }
131
+
132
+ function approve (address spender , uint256 value ) public returns (bool ) {
133
+ require (spender != address (0 ));
134
+ _allowed[msg .sender ][spender] = value;
135
+ emit Approval (msg .sender , spender, value);
136
+ return true ;
137
+ }
138
+
139
+ function transferFrom (address from , address to , uint256 value ) public returns (bool ) {
140
+ require (value <= _balances[from]);
141
+ require (value <= _allowed[from][msg .sender ]);
142
+ require (to != address (0 ));
143
+
144
+ _balances[from] = _balances[from].sub (value);
145
+ _balances[to] = _balances[to].add (value);
146
+ _totalSupply = _totalSupply.sub (value);
147
+
148
+ _allowed[from][msg .sender ] = _allowed[from][msg .sender ].sub (value);
149
+
150
+ emit Transfer (from, to, value);
151
+
152
+ return true ;
153
+ }
154
+
155
+ function increaseAllowance (address spender , uint256 addedValue ) public returns (bool ) {
156
+ require (spender != address (0 ));
157
+ _allowed[msg .sender ][spender] = (_allowed[msg .sender ][spender].add (addedValue));
158
+ emit Approval (msg .sender , spender, _allowed[msg .sender ][spender]);
159
+ return true ;
160
+ }
161
+
162
+ function decreaseAllowance (address spender , uint256 subtractedValue ) public returns (bool ) {
163
+ require (spender != address (0 ));
164
+ _allowed[msg .sender ][spender] = (_allowed[msg .sender ][spender].sub (subtractedValue));
165
+ emit Approval (msg .sender , spender, _allowed[msg .sender ][spender]);
166
+ return true ;
167
+ }
168
+
169
+ function _mint (address account , uint256 amount ) internal {
170
+ require (amount != 0 );
171
+ _balances[account] = _balances[account].add (amount);
172
+ emit Transfer (address (0 ), account, amount);
173
+ }
174
+
175
+ function burn (uint256 amount ) external {
176
+ _burn (msg .sender , amount);
177
+ }
178
+
179
+ function _burn (address account , uint256 amount ) internal {
180
+ require (amount != 0 );
181
+ require (amount <= _balances[account]);
182
+ _totalSupply = _totalSupply.sub (amount);
183
+ _balances[account] = _balances[account].sub (amount);
184
+ emit Transfer (account, address (0 ), amount);
185
+ }
186
+
187
+ function burnFrom (address account , uint256 amount ) external {
188
+ require (amount <= _allowed[account][msg .sender ]);
189
+ _allowed[account][msg .sender ] = _allowed[account][msg .sender ].sub (amount);
190
+ _burn (account, amount);
191
+ }
192
+ }
0 commit comments