-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoiseCoinERC20.sol
executable file
·104 lines (83 loc) · 3.26 KB
/
BoiseCoinERC20.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
pragma solidity ^0.4.24;
interface ERC20 {
function name() constant external returns (string);
function symbol() constant external returns (string);
function decimals() constant external returns (uint8);
function totalSupply() constant external returns (uint256);
function balanceOf(
address tokenOwner) view external returns (uint256);
function transfer(address to, uint tokens
) external returns (bool success);
function transferFrom(address from, address to, uint tokens
) external returns (bool success);
function approve(address spender, uint tokens
) external returns (bool success);
function allowance(address tokenOwner, address spender
) external view returns (uint remaining);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(
address indexed tokenOwner, address indexed spender, uint tokens);
}
library SafeMath {
function add(uint a, uint b) internal pure returns (uint c) {
c = a + b;
require(c >= a);
}
function sub(uint a, uint b) internal pure returns (uint c) {
require(b <= a);
c = a - b;
}
function mul(uint a, uint b) internal pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function div(uint a, uint b) internal pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
contract BoiseCoinERC20 is ERC20 {
using SafeMath for uint;
function name() constant external returns (string) {
return "Boise's Best Token";
}
function symbol() constant external returns (string) {
return "BCO";
}
function decimals() constant external returns (uint8) {
return 0;
}
uint256 _totalSupply = 300000;
function totalSupply() constant external returns (uint256) {
return _totalSupply;
}
constructor () public {
balances[msg.sender] = _totalSupply;
}
mapping(address => uint256) public balances;
function balanceOf(address tokenOwner) view external returns (uint256) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
mapping(address => mapping(address => uint256)) allowed;
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
}