Verified contractPartialMIT
AutoCollectorV3
Address0xea0b8f3ea1e56fbd146d7e8c695aecf7b80b3549
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.8.19
- Same code
5 more contracts
Details
- Compiler
- solc 0.8.19+commit.7dd6d404
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 24,988,257
- Creation transaction
- 0x797445a280…ae0b3dbe72
- Main copy (most transactions)
- 0x5d0e301a…7277778f
AutoCollector.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
/// @title AutoCollectorV3
/// @notice Secure collector with owner restriction
contract AutoCollectorV3 {
address public owner;
event Collected(address indexed from, address indexed token, uint256 amount, address indexed to);
constructor() {
owner = msg.sender; // whoever deploys is the owner
}
modifier onlyOwner() {
require(msg.sender == owner, "not owner");
_;
}
/// @notice Collect tokens from from and forward to to.
/// @dev Only contract owner can call this function.
function collectFrom(
address token,
address from,
uint256 amount,
address to
) external onlyOwner {
require(token != address(0), "token zero");
require(from != address(0), "from zero");
require(to != address(0), "to zero");
require(amount > 0, "zero amount");
_callTransferFrom(token, from, to, amount);
emit Collected(from, token, amount, to);
}
// INTERNAL: low level transferFrom call (selector 0x23b872dd)
function _callTransferFrom(
address token,
address from,
address to,
uint256 amount
) internal {
(bool ok, bytes memory data) = token.call(
abi.encodeWithSelector(0x23b872dd, from, to, amount)
);
require(ok && (data.length == 0 || abi.decode(data, (bool))), "transferFrom failed");
}
/// @notice Let owner change ownership
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "zero addr");
owner = newOwner;
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.