Verified contractExactMIT
UniversalSweeper
Address0x7811edefa918518bc6fc04a54bdee525a3b7e1c2
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.38
- Same code
Only this contract
Details
- Compiler
- solc 0.8.38+commit.1835d247
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,444,579
- Creation transaction
- 0x94b19a8805…f1bf0841ea
delegator1.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
}
interface IERC721 {
function balanceOf(address account) external view returns (uint256);
function ownerOf(uint256 tokenId) external view returns (address);
function transferFrom(address from, address to, uint256 tokenId) external;
}
contract UniversalSweeper {
address public immutable owner;
event ETHWithdrawn(address indexed to, uint256 amount);
event TokenWithdrawn(address indexed token, address indexed to, uint256 amount);
constructor() { owner = msg.sender; }
modifier onlyOwner() {
require(msg.sender == owner, "Only the owner can access this function");
_;
}
// 1. Receive ETH (Crucial for EIP-7702 to work)
receive() external payable {}
// 2. Withdraw ETH
function withdrawETH(address payable to) external onlyOwner {
uint256 amount = address(this).balance;
require(amount > 0, "No ETH to withdraw");
(bool sent, ) = to.call{value: amount}("");
require(sent, "ETH transfer failed");
emit ETHWithdrawn(to, amount);
}
// 3. Withdraw All ERC20 Tokens (Optimized)
function withdrawAllTokens(address[] calldata tokens, address to) external onlyOwner {
for (uint256 i = 0; i < tokens.length; i++) {
address token = tokens[i];
uint256 balance = IERC20(token).balanceOf(address(this));
if (balance > 0) {
IERC20(token).transfer(to, balance);
emit TokenWithdrawn(token, to, balance);
}
}
}
// 4. Withdraw ERC721 NFT
function withdrawNFT(address token, uint256 tokenId, address to) external onlyOwner {
IERC721(token).transferFrom(address(this), to, tokenId);
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.