-
Notifications
You must be signed in to change notification settings - Fork 60
/
ERC20Standard.sol
42 lines (34 loc) · 1.19 KB
/
ERC20Standard.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
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
contract ERC20Standard {
address public owner;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function _transfer(address _from, address _to, uint256 _amount) internal returns (bool) {
balanceOf[_from] -= _amount;
balanceOf[_to] += _amount;
return true;
}
function transfer(address _to, uint256 _amount) public returns (bool) {
return _transfer(msg.sender, _to, _amount);
}
function transferFrom(address _from, address _to, uint256 _amount) public returns (bool) {
allowance[_from][msg.sender] -= _amount;
return _transfer(_from, _to, _amount);
}
function approve(address _spender, uint256 _amount) public {
allowance[msg.sender][_spender] = _amount;
}
function mint(address _receiver, uint256 _amount) public onlyOwner {
balanceOf[_receiver] += _amount;
totalSupply += _amount;
}
}