-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherc20 token.txt
138 lines (91 loc) · 3.94 KB
/
erc20 token.txt
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
abstract contract ERC20_STD{
// ONly Name : Symbols : Decimals
function name() public view virtual returns (string memory);
function symbol() public view virtual returns (string memory);
function decimals() public view virtual returns (uint8);
function totalSupply() public view virtual returns (uint256);
function balanceOf(address _owner) public view virtual returns (uint256 balance);
function transfer(address _to, uint256 _value) public virtual returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) public virtual returns (bool success);
function approve(address _spender, uint256 _value) public virtual returns (bool success);
function allowance(address _owner, address _spender) public view virtual returns (uint256 remaining);
// EVENTS
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract OwnerShip{
address public ContractOwner;
address public newOwner;
event TransferOwnerShip(address indexed _from,address indexed _to);
constructor(){
ContractOwner=msg.sender;
}
function changeOwner(address _to) public{
require(msg.sender== ContractOwner,"only Ownwer of Contract can Execute it.........");
newOwner=_to;
}
function acceptOwner() public{
require(msg.sender==newOwner,"only owner can access this ");
emit TransferOwnerShip(ContractOwner,newOwner);
ContractOwner== newOwner;
newOwner= address(0);
}
}
contract MYERC20 is ERC20_STD,OwnerShip{
string public _name;
string public _symbol;
uint8 public _decimals;
uint256 public _totalSupply;
// Minter
address public _minter;
mapping (address=>uint256) toeknBalances;
mapping(address=>mapping(address=>uint256)) allowed;
constructor(address minter_){
_name="yazib";
_symbol="YY";
_totalSupply=1000000;
_minter=minter_;
toeknBalances[_minter]=_totalSupply;
}
function name() public view override returns (string memory){
return _name;
}
function symbol() public view override returns (string memory){
return _symbol;
}
function decimals() public view override returns (uint8){
return _decimals;
}
function totalSupply() public view override returns (uint256){
return _totalSupply;
}
function balanceOf(address _owner) public view override returns (uint256 balance){
return toeknBalances[_owner];
}
function transfer(address _to, uint256 _value) public override returns (bool success){
require(toeknBalances[msg.sender]>=_value,"insufficient Balance !!!");
toeknBalances[msg.sender] -=_value;
toeknBalances[_to] +=_value;
emit Transfer(msg.sender,_to,_value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public override returns (bool success){
uint256 allowedBal= allowed[_from][msg.sender];
require(allowedBal>=_value,"Insuffcient Balance");
toeknBalances[_from] -=_value;
toeknBalances[_to] +=_value;
emit Transfer(_from,_to,_value);
return true;
}
function approve(address _spender, uint256 _value) public override returns (bool success){
require(toeknBalances[msg.sender]>=_value,"insufficient Balance !!!");
allowed[msg.sender][_spender]= _value;
emit Approval(msg.sender,_spender,_value);
return true;
}
function allowance(address _owner, address _spender) public view override returns (uint256 remaining){
return allowed[_owner][_spender];
}
}