-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy path0-0-3.sol
44 lines (35 loc) · 1.06 KB
/
0-0-3.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
pragma solidity ^0.5.0;
contract Token {
uint256 private totalSupply;
string public name;
string public symbol;
mapping(address => uint256) public balances;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// Safemath
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
constructor() public {
totalSupply = 100000000;
name = "ERC20TokenDemo";
symbol = "ETD";
balances[msg.sender] = totalSupply;
}
function balanceOf(address account) view public returns (uint256) {
return balances[account];
}
function transfer(address to, uint256 amount) public returns (bool) {
balances[msg.sender] = sub(balances[msg.sender], amount);
balances[to] = add(balances[to], amount);
emit Transfer(msg.sender, to, amount);
return true;
}
function () external payable {}
}