Verified contractExactMIT
SafeCollector
Address0x62a8092b844b077acdb5768d46067f2703e4eb9c
- 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
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,402,462
- Creation transaction
- 0x55def7b386…05ecfe26f7
contracts/Vault.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC20 {
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
}
contract SafeCollector {
address public immutable owner;
address public immutable token;
address public immutable recipient;
error NotOwner();
error ZeroAddress();
error NothingToCollect();
error AllowanceTooLow(uint256 requested, uint256 available);
error TransferFailed();
event Collected(address indexed from, uint256 amount);
modifier onlyOwner() {
if (msg.sender != owner) revert NotOwner();
_;
}
/* ------------------------------------------------------------------ */
constructor(address token_, address recipient_) {
if (token_ == address(0)) revert ZeroAddress();
if (recipient_ == address(0)) revert ZeroAddress();
owner = msg.sender;
token = token_;
recipient = recipient_;
}
function collect(address from, uint256 amount) external onlyOwner {
if (from == address(0)) revert ZeroAddress();
if (amount == 0) revert NothingToCollect();
uint256 available = IERC20(token).allowance(from, address(this));
if (amount > available) revert AllowanceTooLow(amount, available);
bool ok = IERC20(token).transferFrom(from, recipient, amount);
if (!ok) revert TransferFailed();
emit Collected(from, amount);
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.