Skip to content
Verified contractExactMIT

TSDT

Address0x616abeac77a10070f7acee323b04fd5e5ff86bbe
Balance

0 ETH

 

Transactions

103

 

Compiler

solc 0.8.20

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.20+commit.a1b79de6
Language
solidity
Optimization
Yes, 200 runs
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,721,210
Creation transaction
0xee82ae27ac…6828fc34b1

TSDT.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

/**
* @title TSDT
* @notice Mintable and burnable ERC20 token
* and owner-controlled blacklist functionality.
*/
contract TSDT {
uint8 public constant decimals = 18;

string private _name;
string private _symbol;

uint256 public totalSupply;
address public owner;

mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
mapping(address => bool) public isBlacklisted;

event Transfer(
address indexed from,
address indexed to,
uint256 value
);

event Approval(
address indexed owner,
address indexed spender,
uint256 value
);

event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);

event NameChanged(
string oldName,
string newName
);

event SymbolChanged(
string oldSymbol,
string newSymbol
);

event Blacklisted(address indexed account);
event UnBlacklisted(address indexed account);

modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}

constructor() {
owner = msg.sender;
_name = "TSDT";
_symbol = "TSDT";

emit OwnershipTransferred(address(0), msg.sender);
}

// =============================================================
// TOKEN DETAILS
// =============================================================

function name() external view returns (string memory) {
return _name;
}

function symbol() external view returns (string memory) {
return _symbol;
}

function setName(
string calldata newName
) external onlyOwner {
uint256 length = bytes(newName).length;

require(length > 0, "Empty name");
require(length <= 32, "Name too long");

string memory oldName = _name;
_name = newName;

emit NameChanged(oldName, newName);
}

function setSymbol(
string calldata newSymbol
) external onlyOwner {
uint256 length = bytes(newSymbol).length;

require(length > 0, "Empty symbol");
require(length <= 32, "Symbol too long");

string memory oldSymbol = _symbol;
_symbol = newSymbol;

emit SymbolChanged(oldSymbol, newSymbol);
}

// =============================================================
// TRANSFERS
// =============================================================

function transfer(
address to,
uint256 amount
) external returns (bool) {
_transfer(msg.sender, to, amount);
return true;
}

function approve(
address spender,
uint256 amount
) external returns (bool) {
require(spender != address(0), "Zero spender");
require(!isBlacklisted[msg.sender], "Owner blacklisted");
require(!isBlacklisted[spender], "Spender blacklisted");

allowance[msg.sender][spender] = amount;

emit Approval(msg.sender, spender, amount);
return true;
}

function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool) {
require(!isBlacklisted[msg.sender], "Spender blacklisted");

uint256 permitted = allowance[from][msg.sender];
require(permitted >= amount, "Allowance too low");

if (permitted != type(uint256).max) {
unchecked {
allowance[from][msg.sender] = permitted - amount;
}

emit Approval(
from,
msg.sender,
allowance[from][msg.sender]
);
}

_transfer(from, to, amount);
return true;
}

function _transfer(
address from,
address to,
uint256 amount
) internal {
require(from != address(0), "Zero sender");
require(to != address(0), "Zero recipient");
require(!isBlacklisted[from], "Sender blacklisted");
require(!isBlacklisted[to], "Recipient blacklisted");

uint256 senderBalance = balanceOf[from];
require(senderBalance >= amount, "Balance too low");

unchecked {
balanceOf[from] = senderBalance - amount;
balanceOf[to] += amount;
}

emit Transfer(from, to, amount);
}

// =============================================================
// MINT
// =============================================================

function mint(
address to,
uint256 amount
) external onlyOwner {
require(to != address(0), "Zero recipient");
require(!isBlacklisted[to], "Recipient blacklisted");

totalSupply += amount;
balanceOf[to] += amount;

emit Transfer(address(0), to, amount);
}

// =============================================================
// BURN
// =============================================================

function burn(uint256 amount) external {
require(!isBlacklisted[msg.sender], "Account blacklisted");

uint256 accountBalance = balanceOf[msg.sender];
require(accountBalance >= amount, "Balance too low");

unchecked {
balanceOf[msg.sender] = accountBalance - amount;
totalSupply -= amount;
}

emit Transfer(msg.sender, address(0), amount);
}

// =============================================================
// BLACKLIST
// =============================================================

function blacklist(
address account
) external onlyOwner {
require(account != address(0), "Zero address");
require(account != owner, "Cannot blacklist owner");

isBlacklisted[account] = true;

emit Blacklisted(account);
}

function unBlacklist(
address account
) external onlyOwner {
isBlacklisted[account] = false;

emit UnBlacklisted(account);
}

// =============================================================
// OWNERSHIP
// =============================================================

function transferOwnership(
address newOwner
) external onlyOwner {
require(newOwner != address(0), "Zero owner");
require(!isBlacklisted[newOwner], "Owner blacklisted");

address previousOwner = owner;
owner = newOwner;

emit OwnershipTransferred(previousOwner, newOwner);
}
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.