Two-role token sweeper that builds the ERC-20 transfer selector at runtime.
Historical Significance
Deriving a function selector from a string literal at runtime, rather than letting the compiler compute it, was a common idiom before typed interface calls became routine. It costs gas and code size on every call to save writing an interface.
Key Facts
Description
A sweeper holding an owner in the first storage slot and an authorized caller in the second. The owner can rotate either role through changeOwner(address) and changeAuthorizedCaller(address). sweep(uint256,address), callable only by the authorized caller, computes the ERC-20 transfer selector at runtime by hashing the string literal "transfer(address,uint256)" and taking its first four bytes, then calls the token to move the balance to the authorized caller. The function naming follows the Bittrex controller lineage. The runtime code matches the deployed bytecode byte for byte; only the trailing swarm metadata hash differs, because the EthereumHistory attribution comment changes the source text. Sourcify records this as a partial match and Etherscan shows it as verified.
Source Verified
Byzantium Era
First Metropolis hard fork. Added zk-SNARK precompiles, REVERT opcode, and staticcall.
Bytecode Overview
Verified Source Available
Source verified through compiler archaeology and exact bytecode matching.
View Verification ProofShow source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
pragma solidity ^0.4.11;
contract Sweeper {
address owner;
address authorizedCaller;
function Sweeper() {
owner = msg.sender;
authorizedCaller = msg.sender;
}
function changeAuthorizedCaller(address _newCaller) {
require(msg.sender == owner);
authorizedCaller = _newCaller;
}
function changeOwner(address _owner) {
require(msg.sender == owner);
owner = _owner;
}
function sweep(uint _amount, address _token) returns (bool) {
require(msg.sender == authorizedCaller);
return _token.call(bytes4(sha3("transfer(address,uint256)")), authorizedCaller, _amount);
}
}