-
Notifications
You must be signed in to change notification settings - Fork 60
/
ERC20USDT.sol
45 lines (36 loc) · 1.26 KB
/
ERC20USDT.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
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
contract ERC20USDT {
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 {
balanceOf[_from] -= _amount;
balanceOf[_to] += _amount;
}
function transfer(address _to, uint256 _amount) public {
_transfer(msg.sender, _to, _amount);
}
function transferFrom(address _from, address _to, uint256 _amount) public {
if (allowance[_from][msg.sender] < type(uint256).max) {
allowance[_from][msg.sender] -= _amount;
}
_transfer(_from, _to, _amount);
}
function approve(address _spender, uint256 _amount) public {
require(!((_amount != 0) && (allowance[msg.sender][_spender] != 0)));
allowance[msg.sender][_spender] = _amount;
}
function mint(address _receiver, uint256 _amount) public onlyOwner {
balanceOf[_receiver] += _amount;
totalSupply += _amount;
}
}