-
Notifications
You must be signed in to change notification settings - Fork 611
Open
Description
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract USDT_TRC20 {
string public name = "Tether";
string public symbol = "USDT";
uint8 public decimals = 6; // Standard for USDT
uint256 public totalSupply;
mapping(address => uint256) public _balances;
mapping(address => mapping(address => uint256)) public _allowances;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor() {
uint256 initialSupply = 10000000 * (10 ** uint256(decimals));
_balances[msg.sender] = initialSupply;
totalSupply = initialSupply;
emit Transfer(address(0), msg.sender, initialSupply);
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
// Overflow/underflow checks are automatic in 0.8.x
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
uint256 currentAllowance = _allowances[sender][msg.sender];
require(currentAllowance >= amount, "TRC20: transfer amount exceeds allowance");
_approve(sender, msg.sender, current Allowance - amount);
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "TRC20: transfer from the zero address");
require(recipient != address(0), "TRC20: transfer to the zero address");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "TRC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
function _approve(address owner, address spender, uint256 amount) internal {
require(owner != address(0), "TRC20: approve from the zero address");
require(spender != address(0), "TRC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
}
Metadata
Metadata
Assignees
Labels
No labels