-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnative_token.sol
32 lines (26 loc) · 1.41 KB
/
native_token.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
contract TS is ERC20, Ownable {
constructor(uint256 initialSupply) ERC20("tether Swap", "TS") Ownable(msg.sender) {
_mint(_msgSender(), initialSupply);
}
function transferHumanReadable(address recipient, uint256 amount) public returns (bool) {
require(recipient != address(0), "Transfer to the zero address not allowed");
uint256 amountInBaseUnits = amount * (10 ** decimals());
require(amountInBaseUnits <= balanceOf(msg.sender), "Insufficient balance");
return super.transfer(recipient, amountInBaseUnits);
}
function burnFrom(address account, uint256 amount) public virtual onlyOwner {
require(account != address(0), "Burn from the zero address not allowed");
uint256 currentAllowance = allowance(account, _msgSender());
require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
_approve(account, _msgSender(), currentAllowance - amount);
_burn(account, amount);
}
function burn(uint256 amount) public virtual {
require(amount <= balanceOf(msg.sender), "Burn amount exceeds balance");
_burn(_msgSender(), amount);
}
}