pragma solidity >=0.4.22 <0.5.0.; library SafeMath { function mul(uint a, uint b) internal pure returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal pure returns (uint) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal pure returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal pure returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } } interface ITRC21 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function estimateFee(uint256 value) external view returns (uint256); function issuer() external view returns (address); function decimals() external view returns (uint8); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); event Fee(address indexed from, address indexed to, address indexed issuer, uint256 value); } contract Ownable is ITRC21 { address public owner; address public waitNewOwner; event transferOwner(address newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner == msg.sender); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. * and safe new contract new owner will be accept owner */ function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { waitNewOwner = newOwner; } } /** * this function accept when transfer to new owner and new owner will be accept owner for safe contract free owner */ function acceptOwnership() public { if(waitNewOwner == msg.sender) { owner = msg.sender; emit transferOwner(msg.sender); }else{ revert(); } } } contract TRC21 is Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; uint256 private _minFee; address private _issuer; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; address private newissuer; event TransferIssuer(address indexed issuer); function totalSupply() public view returns (uint256) { return _totalSupply; } function minFee() public view returns (uint256) { return _minFee; } function issuer() public view returns (address) { return _issuer; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function estimateFee(uint256 value) public view returns (uint256) { return value.mul(0).add(_minFee); } function allowance(address owner,address spender) public view returns (uint256){ return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { uint256 total = value.add(_minFee); require(to != address(0)); require(value <= total); _transfer(msg.sender, to, value); _transfer(msg.sender, _issuer, _minFee); emit Fee(msg.sender, to, _issuer, _minFee); return true; } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); require(_balances[msg.sender]>=_minFee); _allowed[msg.sender][spender] = value; _transfer(msg.sender, _issuer, _minFee); emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { uint256 total = value.add(_minFee); require(to != address(0)); require(value <= total); require(total <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(total); _transfer(from, to, value); _transfer(from, _issuer, _minFee); emit Fee(msg.sender, to, _issuer, _minFee); return true; } function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function _mint(address account, uint256 value) internal { require(account != 0); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } function _changeIssuer(address newIssuer) internal { require(newIssuer != address(0)); _issuer = newIssuer; } function _changeMinFee(uint256 value) internal { _minFee = value; } function OwnerChangeMinFee(uint256 value) onlyOwner public { _minFee = value; } function transferIssuer(address newIssuer) onlyOwner public { if (_issuer != address(0)) { newissuer = newIssuer; } } /** * this function accept when transfer to new owner and new owner will be accept owner for safe contract free owner */ function acceptIssuer() public { if(newissuer == msg.sender) { _issuer = msg.sender; emit TransferIssuer(msg.sender); }else{ revert(); } } } contract MyToken is TRC21 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals, uint256 cap, uint256 minFee) public { _name = name; _symbol = symbol; _decimals = decimals; _mint(msg.sender, cap); _changeIssuer(msg.sender); _changeMinFee(minFee); owner = msg.sender; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } }