forked from xilibi2003/jeth1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherc20.sol
57 lines (44 loc) · 1.63 KB
/
erc20.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
pragma solidity ^0.4.20;
import './erc20interface.sol';
contract ERC20 is ERC20Interface {
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) internal allowed;
constructor() public {
totalSupply = 1000;
name = "JueJin Token";
symbol = "JJT";
decimals = 0;
balanceOf[msg.sender] = totalSupply;
}
function balanceOf(address _owner) view returns (uint256 balance) {
return balanceOf[_owner];
}
function transfer(address _to, uint _value) public returns (bool success) {
require(_to != address(0));
require(_value <= balanceOf[msg.sender]);
require(balanceOf[_to] + _value >= balanceOf[_to]);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
require(_to != address(0));
require(_value <= balanceOf[_from]);
require(_value <= allowed[_from][msg.sender]);
require(balanceOf[_to] + _value >= balanceOf[_to]);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowed[_from][msg.sender] -= _value;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
}