Description:
ERC20 token contract with Mintable, Burnable, Factory capabilities. Standard implementation for fungible tokens on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/USDTzToken.sol": {
"content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.19;\r
\r
/// @title Tether USD Bridged ZED20 (Simple ERC-20)\r
/// @author ChatGPT\r
/// @notice Simple ERC-20 token with initial supply minted to deployer and owner controls.\r
\r
contract USDTzToken {\r
// ERC20 state\r
string public name = "Tether USD Bridged ZED20";\r
string public symbol = "USDT.z";\r
uint8 public decimals = 18;\r
uint256 private _totalSupply;\r
\r
mapping(address => uint256) private _balances;\r
mapping(address => mapping(address => uint256)) private _allowances;\r
\r
// ownership\r
address public owner;\r
\r
// events\r
event Transfer(address indexed from, address indexed to, uint256 value);\r
event Approval(address indexed ownerAddr, address indexed spender, uint256 value);\r
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r
\r
modifier onlyOwner() {\r
require(msg.sender == owner, "Only owner");\r
_;\r
}\r
\r
constructor() {\r
owner = msg.sender;\r
emit OwnershipTransferred(address(0), owner);\r
\r
// initial supply = 1,000,000,000 * 10^18\r
uint256 initial = 1_000_000_000 * (10 ** uint256(decimals));\r
_mint(owner, initial);\r
}\r
\r
// ERC20 basic functions\r
function totalSupply() external view returns (uint256) {\r
return _totalSupply;\r
}\r
\r
function balanceOf(address account) external view returns (uint256) {\r
return _balances[account];\r
}\r
\r
function transfer(address to, uint256 amount) external returns (bool) {\r
_transfer(msg.sender, to, amount);\r
return true;\r
}\r
\r
function allowance(address ownerAddr, address spender) external view returns (uint256) {\r
return _allowances[ownerAddr][spender];\r
}\r
\r
function approve(address spender, uint256 amount) external returns (bool) {\r
_approve(msg.sender, spender, amount);\r
return true;\r
}\r
\r
function transferFrom(address from, address to, uint256 amount) external returns (bool) {\r
uint256 currentAllowance = _allowances[from][msg.sender];\r
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");\r
_approve(from, msg.sender, currentAllowance - amount);\r
_transfer(from, to, amount);\r
return true;\r
}\r
\r
// owner functions\r
/// @notice Owner can mint more tokens (optional)\r
function mint(address to, uint256 amount) external onlyOwner {\r
_mint(to, amount);\r
}\r
\r
/// @notice Owner can burn tokens from an account (optional)\r
function burn(address from, uint256 amount) external onlyOwner {\r
_burn(from, amount);\r
}\r
\r
/// @notice Transfer ownership\r
function transferOwnership(address newOwner) external onlyOwner {\r
require(newOwner != address(0), "New owner zero");\r
emit OwnershipTransferred(owner, newOwner);\r
owner = newOwner;\r
}\r
\r
// internal helpers\r
function _transfer(address from, address to, uint256 amount) internal {\r
require(from != address(0), "ERC20: transfer from zero");\r
require(to != address(0), "ERC20: transfer to zero");\r
uint256 fromBal = _balances[from];\r
require(fromBal >= amount, "ERC20: transfer amount exceeds balance");\r
_balances[from] = fromBal - amount;\r
_balances[to] += amount;\r
emit Transfer(from, to, amount);\r
}\r
\r
function _mint(address account, uint256 amount) internal {\r
require(account != address(0), "ERC20: mint to zero");\r
_totalSupply += amount;\r
_balances[account] += amount;\r
emit Transfer(address(0), account, amount);\r
}\r
\r
function _burn(address account, uint256 amount) internal {\r
require(account != address(0), "ERC20: burn from zero");\r
uint256 accBal = _balances[account];\r
require(accBal >= amount, "ERC20: burn amount exceeds balance");\r
_balances[account] = accBal - amount;\r
_totalSupply -= amount;\r
emit Transfer(account, address(0), amount);\r
}\r
\r
function _approve(address ownerAddr, address spender, uint256 amount) internal {\r
require(ownerAddr != address(0), "ERC20: approve from zero");\r
require(spender != address(0), "ERC20: approve to zero");\r
_allowances[ownerAddr][spender] = amount;\r
emit Approval(ownerAddr, spender, amount);\r
}\r
}\r
"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-11-07 13:06:55
Comments
Log in to comment.
No comments yet.