-
Notifications
You must be signed in to change notification settings - Fork 2
/
TestToken.sol
67 lines (45 loc) · 1.6 KB
/
TestToken.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
pragma solidity ^0.6.1;
contract TestToken{
string public name='Test Token';
string public symbol='Test';
string public standard ='Test Token v1.0';
uint256 public totalSupply;
event Transfer(
address indexed _from,
address indexed _to,
uint256 _value;
)
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value;
)
mapping(address=>uint256) public balanceOf;
mapping(address=>mapping(address=>uint256)) public alllowance;
function TestToken() public{
uint _initialSupply=100000;
balanceOf[msg.sender]=_initialSupply;
totalSupply=_initialSupply;
}
function transfer(address _to,uint256 _value) public returns(bool success){
require(balanceOf[msg.sender]>=_value);
balanceOf[msg.sender]-=_value;
balanceOf[_to]=_value;
Transfer(msg.sender,_to,_value);
return true;
}
function approve(address _spender,uint256 _value ) public returns (bool success){
allowance[msg.sender][_spender]=_value;
Approval(msg.sender,_spender,_value);
return true;
}
function transferFrom(address _from,address _to,uint256 _value) public returns(bool success){
require(_value<=balanceOf[_from]);
require(_value<=allowance[_from][msg.sender]);
balanceOf[_from] -=_value;
balanceOf[_from][msg.sender]-=_value;
allowance[_from][msg.sender]-=_value;
Transfer(_from,_to,_value);
return true;
}
}