Description:
Smart contract deployed on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/// @title Tether USD (USDT) - ERC20 simple token
contract TetherUSDToken {
string public name = "Tether USD";
string public symbol = "USDT";
uint8 public constant decimals = 6;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor() {
uint256 initial = 1_000_000 * (10 ** uint256(decimals)); // 1,000,000 * 10^6
totalSupply = initial;
balanceOf[msg.sender] = initial;
emit Transfer(address(0), msg.sender, initial);
}
function _transfer(address from, address to, uint256 amount) internal {
require(to != address(0), "transfer to zero");
require(balanceOf[from] >= amount, "insufficient balance");
unchecked {
balanceOf[from] -= amount;
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
}
function transfer(address to, uint256 amount) public returns (bool) {
_transfer(msg.sender, to, amount);
return true;
}
function approve(address spender, uint256 amount) public returns (bool) {
require(spender != address(0), "approve zero");
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public returns (bool) {
uint256 current = allowance[from][msg.sender];
require(current >= amount, "allowance exceeded");
unchecked { allowance[from][msg.sender] = current - amount; }
_transfer(from, to, amount);
return true;
}
}
Submitted on: 2025-10-17 09:21:41
Comments
Log in to comment.
No comments yet.