Contract Name:
GOVERNANCETAO
Contract Source Code:
//SPDX-License-Identifier: MIT
pragma solidity 0.8.14;
import "./IERC20.sol";
contract GOVERNANCETAO is IERC20 {
// master contract to inflate supply
address public immutable master;
// total supply
uint256 private _totalSupply;
// token data
string private constant _name = 'GOVERNANCE TAO';
string private constant _symbol = 'GTAO';
uint8 private constant _decimals = 15;
// balances
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
constructor(address master_) {
// set master
master = master_;
// emit transfer to show token on explorer
emit Transfer(address(0), msg.sender, 0);
}
function totalSupply() external view override returns (uint256) { return _totalSupply; }
function balanceOf(address account) public view override returns (uint256) { return _balances[account]; }
function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; }
function name() public pure override returns (string memory) {
return _name;
}
function symbol() public pure override returns (string memory) {
return _symbol;
}
function decimals() public pure override returns (uint8) {
return _decimals;
}
function approve(address spender, uint256 amount) public override returns (bool) {
_allowances[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
/** Transfer Function */
function transfer(address recipient, uint256 amount) external override returns (bool) {
return _transferFrom(msg.sender, recipient, amount);
}
/** Transfer Function */
function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {
require(
_allowances[sender][msg.sender] >= amount,
'Insufficient Allowance'
);
_allowances[sender][msg.sender] -= amount;
return _transferFrom(sender, recipient, amount);
}
function burn(uint256 amount) external returns (bool) {
return _burn(msg.sender, amount);
}
function burnFrom(address account, uint256 amount) external returns (bool) {
require(
_allowances[account][msg.sender] >= amount,
'Insufficient Allowance'
);
_allowances[account][msg.sender] -= amount;
return _burn(account, amount);
}
function mint(address account, uint256 amount) external returns (bool) {
require(msg.sender == master, 'Only Master');
require(
account != address(0),
'Zero Recipient'
);
// increment sender balance
_balances[account] += amount;
_totalSupply += amount;
// emit transfer
emit Transfer(address(0), account, amount);
return true;
}
function withdraw(address token) external {
require(token != address(0), 'Zero Address');
bool s = IERC20(token).transfer(master, IERC20(token).balanceOf(address(this)));
require(s, 'Failure On Token Withdraw');
}
function withdrawETH() external {
(bool s,) = payable(master).call{value: address(this).balance}("");
require(s);
}
/** Internal Transfer */
function _transferFrom(address sender, address recipient, uint256 amount) internal returns (bool) {
require(
recipient != address(0),
'Zero Recipient'
);
require(
amount > 0,
'Zero Amount'
);
require(
amount <= balanceOf(sender),
'Insufficient Balance'
);
// decrement sender balance
_balances[sender] -= amount;
_balances[recipient] += amount;
// emit transfer
emit Transfer(sender, recipient, amount);
return true;
}
function _burn(address account, uint256 amount) internal returns (bool) {
require(
account != address(0),
'Zero Address'
);
require(
amount > 0,
'Zero Amount'
);
require(
amount <= balanceOf(account),
'Insufficient Balance'
);
_balances[account] -= amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
return true;
}
receive() external payable {}
}
//SPDX-License-Identifier: MIT
pragma solidity 0.8.14;
interface IERC20 {
function totalSupply() external view returns (uint256);
function symbol() external view returns(string memory);
function name() external view returns(string memory);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Returns the number of decimal places
*/
function decimals() external view returns (uint8);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}